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

Diego Novillo dnovillo@redhat.com
Wed Aug 13 11:53:00 GMT 2003


On Sun, 2003-08-10 at 16:37, Zdenek Dvorak wrote:

> 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. 
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.


> + /* 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?


Diego.



More information about the Gcc-patches mailing list