]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/39100 (-fstrict-aliasing miscompilation)
authorRichard Guenther <rguenther@suse.de>
Thu, 5 Feb 2009 11:10:02 +0000 (11:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 5 Feb 2009 11:10:02 +0000 (11:10 +0000)
2009-02-05  Daniel Berlin  <dberlin@dberlin.org>
            Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/39100
        * tree-ssa-structalias.c (do_ds_constraint): Actually do what the
        comment says and add edges.

From-SVN: r143961

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr39100.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 94a8bd2a5edc9d659c5732d869108709100db512..9b76c05faa009304739a97fd4d1368f93a06f088 100644 (file)
@@ -1,3 +1,13 @@
+2009-02-05  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2009-02-05  Daniel Berlin  <dberlin@dberlin.org>
+           Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/39100
+       * tree-ssa-structalias.c (do_ds_constraint): Actually do what the
+       comment says and add edges.
+
 2009-02-04  Ramana Radhakrishnan  <ramana.r@gmail.com>
 
        PR rtl-optimization/39076
index 978481d542c53fc478903c058f96dbdcecbc124f..1590b1adb310202450108bc556e3448bcff30ba0 100644 (file)
@@ -1,3 +1,10 @@
+2009-02-05  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2009-02-05  Daniel Berlin  <dberlin@dberlin.org>
+
+       * gcc.c-torture/execute/pr39100.c: New.
+
 2009-02-04  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/35433
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr39100.c b/gcc/testsuite/gcc.c-torture/execute/pr39100.c
new file mode 100644 (file)
index 0000000..5cb9e25
--- /dev/null
@@ -0,0 +1,65 @@
+/* Bad PTA results (incorrect store handling) was causing us to delete
+   *na = 0 store.  */
+
+typedef struct E
+{
+  int p;
+  struct E *n;
+} *EP;   
+
+typedef struct C
+{
+  EP x;
+  short cn, cp; 
+} *CP;
+
+__attribute__((noinline)) CP
+foo (CP h, EP x)
+{
+  EP pl = 0, *pa = &pl;
+  EP nl = 0, *na = &nl;
+  EP n;
+
+  while (x)
+    {
+      n = x->n;   
+      if ((x->p & 1) == 1) 
+        {
+          h->cp++;
+          *pa = x;
+          pa = &((*pa)->n);
+        }
+      else
+        {
+          h->cn++;
+          *na = x;
+          na = &((*na)->n);
+        }    
+      x = n;
+    }
+  *pa = nl;
+  *na = 0;
+  h->x = pl;
+  return h;
+}
+
+int
+main (void)
+{  
+  struct C c = { 0, 0, 0 };
+  struct E e[2] = { { 0, &e[1] }, { 1, 0 } };
+  EP p;
+
+  foo (&c, &e[0]);
+  if (c.cn != 1 || c.cp != 1)
+    __builtin_abort ();
+  if (c.x != &e[1])
+    __builtin_abort ();
+  if (e[1].n != &e[0])
+    __builtin_abort ();
+  if (e[0].n)
+    __builtin_abort ();
+  return 0;  
+}
+
+
index c0a47c36356237f46c11c9a28c89c25afa7ae023..97c4fb32c73c6c50f3d16d5862483107dc0797a7 100644 (file)
@@ -1509,24 +1509,23 @@ do_ds_constraint (constraint_t c, bitmap delta)
          varinfo_t v;
          unsigned int t;
          unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + loff;
-         bitmap tmp;
 
          v = first_vi_for_offset (get_varinfo (j), fieldoffset);
          /* If the access is outside of the variable we can ignore it.  */
          if (!v)
            continue;
          t = find (v->id);
-         tmp = get_varinfo (t)->solution;
-
-         if (set_union_with_increment (tmp, sol, 0))
+         if (add_graph_edge (graph, t, rhs))
            {
-             get_varinfo (t)->solution = tmp;
-             if (t == rhs)
-               sol = get_varinfo (rhs)->solution;
-             if (!TEST_BIT (changed, t))
+             if (bitmap_ior_into (get_varinfo (t)->solution, sol))
                {
-                 SET_BIT (changed, t);
-                 changed_count++;
+                 if (t == rhs)
+                   sol = get_varinfo (rhs)->solution;
+                 if (!TEST_BIT (changed, t))
+                   {
+                     SET_BIT (changed, t);
+                     changed_count++;
+                   }
                }
            }
        }