This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]