This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR49651
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jul 2011 16:48:27 +0200 (CEST)
- Subject: [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;
+ }