[PATCH][4.3] Backport the fix for PR38051 (fix PR38478)

Richard Guenther rguenther@suse.de
Wed Dec 10 19:32:00 GMT 2008


So much for what you think probably doesn't happen on the branch (I knew
the problem was latent).  Thus, here's the backport of the PR38051 fix,
bootstrapped / tested multiple times for all SUSE archs, applied to the
branch.

Richard.

2008-12-10  Richard Guenther  <rguenther@suse.de>

	Backport from trunk the fix for PR38051.

	PR tree-optimization/38478
	* tree-ssa-structalias.c (update_alias_info): Manually find
	written variables.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 141900)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** update_alias_info (tree stmt, struct ali
*** 3467,3472 ****
--- 3467,3495 ----
  
        mem_ref_stats->num_mem_stmts++;
  
+       /* Add all decls written to to the list of written variables.  */
+       if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
+ 	  && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) != SSA_NAME)
+ 	{
+ 	  tree lhs = GIMPLE_STMT_OPERAND (stmt, 0);
+ 	  while (handled_component_p (lhs))
+ 	    lhs = TREE_OPERAND (lhs, 0);
+ 	  if (DECL_P (lhs))
+ 	    {
+ 	      subvar_t svars;
+ 	      if (var_can_have_subvars (lhs)
+ 		  && (svars = get_subvars_for_var (lhs)))
+ 		{
+ 		  unsigned int i;
+ 		  tree subvar;
+ 		  for (i = 0; VEC_iterate (tree, svars, i, subvar); ++i)
+ 		    pointer_set_insert (ai->written_vars, subvar);
+ 		}
+ 	      else
+ 		pointer_set_insert (ai->written_vars, lhs);
+ 	    }
+ 	}
+ 
        /* Notice that we only update memory reference stats for symbols
  	 loaded and stored by the statement if the statement does not
  	 contain pointer dereferences and it is not a call/asm site.
*************** update_alias_info (tree stmt, struct ali
*** 3489,3513 ****
  	 dereferences (e.g., MEMORY_VAR = *PTR) or if a call site has
  	 memory symbols in its argument list, but these cases do not
  	 occur so frequently as to constitute a serious problem.  */
-       if (STORED_SYMS (stmt))
- 	EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
- 	  {
- 	    tree sym = referenced_var (i);
- 	    pointer_set_insert (ai->written_vars, sym);
- 	    if (!stmt_dereferences_ptr_p
- 		&& stmt_escape_type != ESCAPE_TO_CALL
- 		&& stmt_escape_type != ESCAPE_TO_PURE_CONST
- 		&& stmt_escape_type != ESCAPE_TO_ASM)
- 	      update_mem_sym_stats_from_stmt (sym, stmt, 0, 1);
- 	  }
- 
        if (!stmt_dereferences_ptr_p
- 	  && LOADED_SYMS (stmt)
  	  && stmt_escape_type != ESCAPE_TO_CALL
  	  && stmt_escape_type != ESCAPE_TO_PURE_CONST
  	  && stmt_escape_type != ESCAPE_TO_ASM)
! 	EXECUTE_IF_SET_IN_BITMAP (LOADED_SYMS (stmt), 0, i, bi)
! 	  update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 1, 0);
      }
  }
  
--- 3512,3530 ----
  	 dereferences (e.g., MEMORY_VAR = *PTR) or if a call site has
  	 memory symbols in its argument list, but these cases do not
  	 occur so frequently as to constitute a serious problem.  */
        if (!stmt_dereferences_ptr_p
  	  && stmt_escape_type != ESCAPE_TO_CALL
  	  && stmt_escape_type != ESCAPE_TO_PURE_CONST
  	  && stmt_escape_type != ESCAPE_TO_ASM)
! 	{
! 	  if (STORED_SYMS (stmt))
! 	    EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
! 	      update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 0, 1);
! 
! 	  if (LOADED_SYMS (stmt))
! 	    EXECUTE_IF_SET_IN_BITMAP (LOADED_SYMS (stmt), 0, i, bi)
! 	      update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 1, 0);
! 	}
      }
  }
  



More information about the Gcc-patches mailing list