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] Fix PR33199, alias problem with call results (?)


The following patch fixes(?) PR33199 by not ignoring call results
for constraint generation but creating a constraint pointing to
anything for pointer results that are assigned.

Bootstrapped and tested on x86_64-unknown-linux-gnu, the testcase
in PR33199 now passes.

Ok for mainline?

Thanks,
Richard.

2007-08-30  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/33199
	* tree-ssa-structalias.c (handle_lhs_call): New function.
	(find_func_aliases): In non-IPA mode make sure that for
	calls that return a pointer we add a constraint for the
	result to point to anything.

Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c	(revision 127848)
--- tree-ssa-structalias.c	(working copy)
*************** handle_rhs_call  (tree rhs)
*** 3655,3660 ****
--- 3655,3681 ----
      }
  }
  
+ /* For non-IPA mode, generate constraints necessary for a call
+    that returns a pointer and assigns it to LHS.  This simply makes
+    the LHS point to anything.  */
+ 
+ static void
+ handle_lhs_call (tree lhs)
+ {
+   VEC(ce_s, heap) *lhsc = NULL;
+   struct constraint_expr rhsc;
+   unsigned int j;
+   struct constraint_expr *lhsp;
+ 
+   rhsc.var = anything_id;
+   rhsc.offset = 0;
+   rhsc.type = ADDRESSOF;
+   get_constraint_for (lhs, &lhsc);
+   for (j = 0; VEC_iterate (ce_s, lhsc, j, lhsp); j++)
+     process_constraint_1 (new_constraint (*lhsp, rhsc), true);
+   VEC_free (ce_s, heap, lhsc);
+ }
+ 
  /* Walk statement T setting up aliasing constraints according to the
     references found in T.  This function is the main part of the
     constraint builder.  AI points to auxiliary alias information used
*************** find_func_aliases (tree origt)
*** 3726,3732 ****
        if (!in_ipa_mode)
  	{
  	  if (TREE_CODE (t) == GIMPLE_MODIFY_STMT)
! 	    handle_rhs_call (GIMPLE_STMT_OPERAND (t, 1));
  	  else
  	    handle_rhs_call (t);
  	}
--- 3747,3757 ----
        if (!in_ipa_mode)
  	{
  	  if (TREE_CODE (t) == GIMPLE_MODIFY_STMT)
! 	    {
! 	      handle_rhs_call (GIMPLE_STMT_OPERAND (t, 1));
! 	      if (POINTER_TYPE_P (TREE_TYPE (GIMPLE_STMT_OPERAND (t, 1))))
! 		handle_lhs_call (GIMPLE_STMT_OPERAND (t, 0));
! 	    }
  	  else
  	    handle_rhs_call (t);
  	}


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