This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Fix variables getting out of their scope
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>,"gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 13 Aug 2003 19:14:53 +0200
- Subject: Re: [tree-ssa] Fix variables getting out of their scope
- References: <20030810203732.GA27897@kam.mff.cuni.cz> <1060773437.3156.48.camel@frodo.toronto.redhat.com>
Hello,
> > Changelog:
> > * tree-flow.h (struct block_tree): New.
> > (block_tree): Declare.
> >
> Why is this necessary? Why not use the existing BLOCK_* macros? As we
> build the CFG we annotate statements with the BLOCK that contains them.
I am not quite sure what you refer to here? Neither stmt_ann_d nor
bb_ann_d contain anything that seems related.
> Otherwise, you're duplicating functionality.
>
> The block depth number can be initialized in a similar way as it's done
> for the RTL flowgraph in set_block_levels.
>
>
> > *************** propagate_copy (tree *op_p, tree var)
> > *** 225,228 ****
> > --- 230,271 ----
> > }
> >
> > *op_p = var;
> > +
> > + old_scope = var_ann (SSA_NAME_VAR (var))->scope;
> > + if (old_scope)
> >
> old_scope should always exist. We don't copy propagate globals.
But since the scope is not set for newly created variables (and I did
not want to try finding all places where it occurs), I use the fact
that they don't have it set as indication
> > + /* Moves variable VAR from OLD_SCOPE to SCOPE. */
> > + static void
> > + move_var_to_scope (tree var, struct block_tree *old_scope,
> > + struct block_tree *scope)
> > + {
> > + tree *ch;
> > +
> > + for (ch = &BIND_EXPR_VARS (old_scope->bind); *ch; ch = &TREE_CHAIN (*ch))
> > + if (*ch == var)
> > + break;
> > + if (!*ch)
> > + abort ();
> > + *ch = TREE_CHAIN (*ch);
> > +
> > + TREE_CHAIN (var) = BIND_EXPR_VARS (scope->bind);
> > + BIND_EXPR_VARS (scope->bind) = var;
> > + var_ann (var)->scope = scope;
> > +
> > + /* ??? Not sure why, but it makes dwarf2out happy. */
> > + DECL_ABSTRACT_ORIGIN (var) = NULL_TREE;
> >
> Could you find out? What happens if DECL_ABSTRACT_ORIGIN(var) was not
> NULL to begin with?
it aborts in add_abstract_origin_attribute. It happens in situation when
a variable declared inside inlined function is moved out of it, so I
think resetting DECL_ABSTRACT_ORIGIN is appropriate, but I am a bit
unsure about it.
Zdenek