This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] variables being dragged out of their lexical scopes
- From: Jan Vroonhof <jan dot vroonhof at ntlworld dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 01 May 2003 19:07:25 +0100
- Subject: Re: [tree-ssa] variables being dragged out of their lexical scopes
- References: <20030501142431.GB18264@tornado.toronto.redhat.com>
Diego Novillo <dnovillo@redhat.com> writes:
> I see two ways of handling this:
>
> 1- Never allow copy propagation in expressions of the form 'VAR = TEMP'
> (where 'VAR' is a program variable and 'TEMP' a compiler
> temporary). This could work but I'm not sure if it would be a
> valid long term approach.
>
> 2- While building the flowgraph, emit a group-clobber instruction
> for all the variables that were declared inside a lexical
> scope. The clobber instruction would be a new GIMPLE
> statement of the form CLOBBER_EXPR <var1, var2, ..., varN>.
> This would avoid any code movement that tries to take
> variables outside of their original scope (and it would also
> avoid having to generate all those temporaries in the
> gimplifier).
Wouldn't both of them have essentially the same effect of stopping
some valid propagation optimizations to preserve debugability? Seems
like too high a price to pay. Presumably after aggressive optimization
the code flow will jump through the lexical structure in "interesting"
ways anyway?
How about
3 When copy propagating in expressions of the form 'VAR =' as above
would result in VARFOO_x = VARBAR_y where both are program variables
and VARBAR wouldn't be in scope, instead of replacing all future
occurrences of VARFOO_x by VARBAR_y, create a new SSA name VARFOO_z
and replace all occurrences of VARBAR_y by VARFOO_z
i.e.
foo ()
{
int i;
int k;
int T.1;
# BLOCK 0 (a.c:6). PRED: -1. SUCC: -2.
{
int j;
T.1_5 = i_1 + 1;
k_4 = T.1_5;
};
k_3 = k_4;
return i_1;
}
I am not event sure it would be necessary to create the new SSA name.