]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/45120 (-fipa-pta causes FAIL: gcc.c-torture/execute/pta-field...
authorRichard Guenther <rguenther@suse.de>
Thu, 29 Jul 2010 12:30:09 +0000 (12:30 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 29 Jul 2010 12:30:09 +0000 (12:30 +0000)
2010-07-29  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/45120
* tree-ssa-structalias.c (get_constraint_for_component_ref):
Handle offset in DEREFs properly.
(get_constraint_for_1): Handle MEM_REF offset properly.

* gcc.dg/ipa/ipa-pta-15.c: New testcase.

From-SVN: r162676

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ipa-pta-15.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 5c066b524b4c4e7979f895f7b958fb93230b4ed0..45155e417f5ab9fe8b75eb5e57d472de570b4dda 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-29  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45120
+       * tree-ssa-structalias.c (get_constraint_for_component_ref):
+       Handle offset in DEREFs properly.
+       (get_constraint_for_1): Handle MEM_REF offset properly.
+
 2010-07-29  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/45034
index fdb52bd338ceced85589a07b6d66ccd3683a65e9..35415a3d55f24504015ec6ca6a4ba9acbd416a8c 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-29  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45120
+       * gcc.dg/ipa/ipa-pta-15.c: New testcase.
+
 2010-07-29  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/42051
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-pta-15.c b/gcc/testsuite/gcc.dg/ipa/ipa-pta-15.c
new file mode 100644 (file)
index 0000000..77701eb
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fipa-pta" } */
+
+struct Foo {
+  int *p;
+  int *q;
+};
+
+void __attribute__((noinline))
+bar (int **x)
+{
+  struct Foo *f = (struct Foo *)(x - 1);
+  *(f->p) = 0;
+}
+
+int foo(void)
+{
+  struct Foo f;
+  int i = 1, j = 2;
+  f.p = &i;
+  f.q = &j;
+  bar(&f.q);
+  return i;
+}
+
+extern void abort (void);
+int main()
+{
+  if (foo () != 0)
+    abort ();
+  return 0;
+}
index cf5815f67e5064e12ea8088599499768a967591b..37fc6f83a38b818a1f3d8b425fd45ec4603e0478 100644 (file)
@@ -3208,10 +3208,11 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
         at most one subfiled of any variable.  */
       if (bitpos == -1
          || bitsize != bitmaxsize
-         || AGGREGATE_TYPE_P (TREE_TYPE (orig_t)))
+         || AGGREGATE_TYPE_P (TREE_TYPE (orig_t))
+         || result->offset == UNKNOWN_OFFSET)
        result->offset = UNKNOWN_OFFSET;
       else
-       result->offset = bitpos;
+       result->offset += bitpos;
     }
   else if (result->type == ADDRESSOF)
     {
@@ -3345,8 +3346,8 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p)
          {
          case MEM_REF:
            {
-             get_constraint_for_ptr_offset (TREE_OPERAND (t, 0),
-                                            TREE_OPERAND (t, 1), results);
+             tree off = double_int_to_tree (sizetype, mem_ref_offset (t));
+             get_constraint_for_ptr_offset (TREE_OPERAND (t, 0), off, results);
              do_deref (results);
              return;
            }