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]

[PATCH][alias-improvements] Fix PR39358 fix


When merging from trunk I inherited the PR39358 fix (wrong points-to
with ESCAPED) which was slightly bogus (or rather, exposed issues 
elsewhere) and thus caused 197.parser to miscompare on the branch.

There are multiple issues,

 1) when propagating along copy edges we do not really want to disable
 propagation for the ESCAPED solution node but instead we want ESCAPED
 to be propagated (not its solution).  It turns out that when we unify
 variables we do have copy edges that are necessary to process.

 2) may_point_to_global_var was not properly looking inside the ESCAPED
 solution.  Fixed by adding a points-to solution query for globals.

1) needs also fixing on the trunk, I am testing a backport.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
branch.

Richard.

2009-03-16  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (do_sd_constraint): Simplify check
	for escaped_id.
	(solve_graph): Do not disable propagation from escaped
	completely.  Instead properly only propagate escaped_id.
	(pt_solution_includes_global): New function.
	* tree-ssa-alias.c (pt_solution_includes_global): Declare.
	* tree-ssa-alias.c (may_point_to_global_var): Use
	pt_solution_includes_global.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 144880)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** do_sd_constraint (constraint_graph_t gra
*** 1584,1590 ****
  	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
  	  /* Merging the solution from ESCAPED needlessly increases
  	     the set.  Use ESCAPED as representative instead.  */
! 	  else if (get_varinfo (t)->id == find (escaped_id))
  	    flag |= bitmap_set_bit (sol, escaped_id);
  	  else if (add_graph_edge (graph, lhs, t))
  	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
--- 1584,1590 ----
  	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
  	  /* Merging the solution from ESCAPED needlessly increases
  	     the set.  Use ESCAPED as representative instead.  */
! 	  else if (v->id == escaped_id)
  	    flag |= bitmap_set_bit (sol, escaped_id);
  	  else if (add_graph_edge (graph, lhs, t))
  	    flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
*************** solve_graph (constraint_graph_t graph)
*** 2539,2549 ****
  
  	      solution_empty = bitmap_empty_p (solution);
  
! 	      if (!solution_empty
! 		  /* Do not propagate the ESCAPED solution.  */
! 		  && i != find (escaped_id))
  		{
  		  bitmap_iterator bi;
  
  		  /* Propagate solution to all successors.  */
  		  EXECUTE_IF_IN_NONNULL_BITMAP (graph->succs[i],
--- 2539,2548 ----
  
  	      solution_empty = bitmap_empty_p (solution);
  
! 	      if (!solution_empty)
  		{
  		  bitmap_iterator bi;
+ 		  unsigned eff_escaped_id = find (escaped_id);
  
  		  /* Propagate solution to all successors.  */
  		  EXECUTE_IF_IN_NONNULL_BITMAP (graph->succs[i],
*************** solve_graph (constraint_graph_t graph)
*** 2560,2566 ****
  		      if (to == i)
  			continue;
  
! 		      flag = set_union_with_increment (tmp, pts, 0);
  
  		      if (flag)
  			{
--- 2559,2570 ----
  		      if (to == i)
  			continue;
  
! 		      /* If we propagate from ESCAPED use ESCAPED as
! 		         placeholder.  */
! 		      if (i == eff_escaped_id)
! 			flag = bitmap_set_bit (tmp, escaped_id);
! 		      else
! 			flag = set_union_with_increment (tmp, pts, 0);
  
  		      if (flag)
  			{
*************** pt_solution_empty_p (struct pt_solution
*** 4986,4991 ****
--- 4990,5012 ----
    return true;
  }
  
+ /* Return true if the points-to solution *PT includes global memory.  */
+ 
+ bool
+ pt_solution_includes_global (struct pt_solution *pt)
+ {
+   if (pt->anything
+       || pt->nonlocal
+       || pt->vars_contains_global)
+     return true;
+ 
+   if (pt->escaped
+       && pt != &cfun->gimple_df->escaped)
+     return pt_solution_includes_global (&cfun->gimple_df->escaped);
+ 
+   return false;
+ }
+ 
  /* Return true if the points-to solution *PT includes the variable
     declaration DECL.  */
  
Index: gcc/tree-ssa-alias.h
===================================================================
*** gcc/tree-ssa-alias.h	(revision 144880)
--- gcc/tree-ssa-alias.h	(working copy)
*************** extern void dump_alias_stats (FILE *);
*** 96,101 ****
--- 96,102 ----
  /* In tree-ssa-structalias.c  */
  extern unsigned int compute_may_aliases (void);
  extern void delete_alias_heapvars (void);
+ extern bool pt_solution_includes_global (struct pt_solution *);
  extern bool pt_solution_includes (struct pt_solution *, const_tree);
  extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
  extern void pt_solution_reset (struct pt_solution *);
Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c	(revision 144880)
--- gcc/tree-ssa-alias.c	(working copy)
*************** may_point_to_global_var (tree ptr)
*** 156,162 ****
    if (!pi)
      return true;
  
!   return pi->pt.anything || pi->pt.nonlocal || pi->pt.vars_contains_global;
  }
  
  /* Return true if PTR may point to DECL.  */
--- 156,162 ----
    if (!pi)
      return true;
  
!   return pt_solution_includes_global (&pi->pt);
  }
  
  /* Return true if PTR may point to DECL.  */


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