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


On Thu, 2003-08-14 at 18:09, Zdenek Dvorak wrote:

> 	* tree-flow.h (struct var_ann_d): New field scope.
> 	(struct stmt_ann_d): New field scope.
> 	(propagate_copy): Declaration changed.
> 	* tree-cfg.c (make_blocks, make_cond_expr_blocks,
> 	make_catch_expr_blocks, make_eh_filter_expr_blocks,
> 	make_try_expr_blocks, make_loop_expr_blocks, make_switch_expr_blocks,
> 	make_bind_expr_blocks, build_tree_cfg): Assign variables and statements
> 	to scopes.
> 	(assign_vars_to_scope): New.
> 	* tree-ssa-copyprop.c (move_var_to_scope): New.
> 	(copyprop_stmt): Pass scope of statement to propagate_copy.
> 	(propagate_copy): Assign variable to the right bind_expr.
> 	* tree-ssa-dom.c (optimize_stmt): Pass scope of statement to
> 	propagate_copy.
> 
Has this been bootstrapped and tested?  If so, the patch is OK after a
couple of minor changes:


> *************** clear_blocks_annotations (void)
> *** 381,393 ****
>      BB is the block where the statements should be added to.  If BB is NULL,
>         a new basic block will be created for the statements.
>   
>      Return the last basic block added to the graph.  This is used to know if
>      a recursive invocation built a sub-graph whose last block can accept
>      more statements or not.  */
>   
>   static basic_block
>   make_blocks (tree *first_p, tree next_block_link, tree parent_stmt,
> ! 	     basic_block bb)
>   {
>     tree_stmt_iterator i;
>     tree stmt, last;
> --- 383,397 ----
>      BB is the block where the statements should be added to.  If BB is NULL,
>         a new basic block will be created for the statements.
>   
> +    SCOPE is the actual bind block.
> +    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
SCOPE is the BIND_EXPR block containing *FIRST_P.

  
> *************** make_loop_expr_blocks (tree *loop_p, bas
> *** 589,599 ****
>         lexical scope, this will be the statement that comes after COND_P's
>         container (see the documentation for NEXT_BLOCK_LINK).
>   
> !    ENTRY is the block whose last statement is *COND_P.  */
>   
>   static void
>   make_cond_expr_blocks (tree *cond_p, tree next_block_link,
> ! 		       basic_block entry)
>   {
>     tree_stmt_iterator si;
>     tree cond = *cond_p;
> --- 597,609 ----
>         lexical scope, this will be the statement that comes after COND_P's
>         container (see the documentation for NEXT_BLOCK_LINK).
>   
> !    ENTRY is the block whose last statement is *COND_P.
> !    
> !    SCOPE is the bind scope to that it belongs.  */
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
SCOPE is the BIND_EXPR node holding *COND_P.  Similarly, in the other
make_*_blocks, we're missing documentation for SCOPE.


> *************** struct stmt_ann_d GTY(())
> *** 232,237 ****
> --- 235,246 ----
>   
>     /* Array of variables that have had their address taken in the statement.  */
>     varray_type addresses_taken;
> + 
> +   /* The binding block to that the statement belongs.  */
> +   tree scope;
> + 
> +   /* For BIND_EXPRs, a level of the scope.  */
> +   int scope_level;
>     ^^^^^^^^^^^^^^^^
>
Not needed.  You can use BLOCK_NUMBER (BIND_EXPR_BLOCK (scope))


Diego.


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