[tree-ssa] variables being dragged out of their lexical scopes

Jan Vroonhof jan.vroonhof@ntlworld.com
Thu May 1 18:07:00 GMT 2003


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.



More information about the Gcc mailing list