[tree-ssa] Fix variables getting out of their scope

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Mon Aug 11 19:19:00 GMT 2003


Hello,

> > > If not, then I would vote for moving *all* local declarations to the top
> > > BIND_EXPR and remove all BIND_EXPRs inside the function.  IIRC, I once
> > > suggested something along those lines but it didn't turn out to be a
> > > good idea because it would break debugging info.
> > This would break debugging regardless of optimization level. Zdenek's
> > change only causes debugging info to break when we can't avoid it.
> > One is acceptable to gcc, the other is not.
> >
> Moving all local declarations to the top BIND_EXPR would only occur with
> optimization.  By what you said earlier, it should also be OK.  I don't
> understand the distinction you're making here.

well, there is one important distinction -- I only clobber the debugging
information when neccessary, which is more acceptable than breaking it
altogether.

Then there are two problems:
1) moving variables to the outer scope might pessimize the code a bit.
Now when the variables are in disjoint scopes, they may get the same
stack slot assigned (if any).  Not really sure whether we use this,
though.
2) You will run into problems with code like

{
  int z = something complicated;
   
  {
    int array[z];
  }
}

Zdenek



More information about the Gcc-patches mailing list