This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] a tree-ssa beginner question - creating new variables
- From: law at redhat dot com
- To: Dorit Naishlos <DORIT at il dot ibm dot com>
- Cc: gcc at gcc dot gnu dot org, Diego Novillo <dnovillo at redhat dot com>
- Date: Mon, 05 Jan 2004 22:54:10 -0700
- Subject: Re: [tree-ssa] a tree-ssa beginner question - creating new variables
- Reply-to: law at redhat dot com
In message <OF33AAF817.9987F0C2-ONC2256E03.00621942-C2256E03.00667FCB@il.ibm.co
m
>, Dorit Naishlos writes:
>
>
>
>
>I thought I figured out how to create new temporaries in tree-ssa, but
>looks like my first toy-example passed compilation by pure luck. The second
>toy-example failed during rewrite_out_of_ssa() at the end of
>create_ssa_var_map() in tree-ssa-live.c, with the error: "Variable c used
>in real and virtual operands".
>
>As far as I could see, the reason this happens is that for all the new
>variables that I created, their 'var_ann ( )->uid' is 0, which in this
>case happens to also be the uid of the var_ann of variable 'c' (which is a
>user declared variable).
>
>what's the correct way to create temp variables ?
>
>(the way I created new vars:
>
>T0 = create_tmp_var (some_type, some_name);
>create_var_ann (T0);
>set_is_used (T0);)
You might want to do something like this (see create_tmp):
tmp = create_tmp_var (type, name);
create_var_ann (tmp);
set_is_used (tmp);
/* We have just created a new variable. Make sure it has a UID and
an appropriate memory tag, then put it in REFERENCED_VARS. */
var_ann (tmp)->uid = num_referenced_vars;
var_ann (tmp)->mem_tag = var_ann (t)->mem_tag;
VARRAY_PUSH_TREE (referenced_vars, tmp);
>Is it ok to create ssa names to new variables as I am introducing new
>variables/stmts, or should I call rewrite_to_ssa at the end of my
>optimization pass instead?
Well, if you know precisely what the SSA graph for those variables looks
like, then it ought to be OK to go ahead and put them in SSA form yourself.
However, if it's not insanely trivial, then I'd suggest marking the new
variables as needing to be rewritten and letting rewrite_innto_ssa do
the work.
Jeff