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 PR49651


This fixes PR49651 where we fail to handle aggregate dereferences
in call arguments in PTA properly.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied
where applicable.

Richard.

2011-07-14  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/49651
	* tree-ssa-structalias.c (get_constraint_for_1): Properly
	handle dereferences with subvariables.

	* gcc.dg/torture/pr49651.c: New testcase.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 176272)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** get_constraint_for_1 (tree t, VEC (ce_s,
*** 3349,3357 ****
  
  	      /* If we are not taking the address then make sure to process
  		 all subvariables we might access.  */
  	      cs = *VEC_last (ce_s, *results);
! 	      if (address_p
! 		  || cs.type != SCALAR)
  		return;
  
  	      vi = get_varinfo (cs.var);
--- 3349,3366 ----
  
  	      /* If we are not taking the address then make sure to process
  		 all subvariables we might access.  */
+ 	      if (address_p)
+ 		return;
+ 
  	      cs = *VEC_last (ce_s, *results);
! 	      if (cs.type == DEREF)
! 		{
! 		  /* For dereferences this means we have to defer it
! 		     to solving time.  */
! 		  VEC_last (ce_s, *results)->offset = UNKNOWN_OFFSET;
! 		  return;
! 		}
! 	      if (cs.type != SCALAR)
  		return;
  
  	      vi = get_varinfo (cs.var);
Index: gcc/testsuite/gcc.dg/torture/pr49651.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr49651.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr49651.c	(revision 0)
***************
*** 0 ****
--- 1,31 ----
+ /* { dg-do run } */
+ 
+ extern void abort (void);
+ 
+ struct X {
+     int *p;
+     int *q;
+ };
+ 
+ void __attribute__((noinline, noclone))
+ foo (struct X x) { *x.q = 0; }
+ 
+ volatile int what;
+ struct X y;
+ 
+ int main()
+ {
+   int i, j;
+   struct X x, *p;
+   x.p = &i;
+   x.q = &j;
+   if (what)
+     p = &y;
+   else
+     p = &x;
+   j = 1;
+   foo (*p);
+   if (j != 0)
+     abort ();
+   return 0;
+ }


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