re PR tree-optimization/80713 (recent crash in update_dep_bb)
authorRichard Biener <rguenther@suse.de>
Fri, 12 May 2017 10:54:29 +0000 (10:54 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 12 May 2017 10:54:29 +0000 (10:54 +0000)
2017-05-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/80713
* tree-ssa-pre.c (remove_dead_inserted_code): Clear
inserted_exprs bit for not removed stmts.

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

From-SVN: r247963

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr80713.c [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 580a3db9853cfd7e3fe8921ff0ec5d1a73e4f3f4..988e8c795d44f3f9a253bedd93719186e0d9c6d6 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80713
+       * tree-ssa-pre.c (remove_dead_inserted_code): Clear
+       inserted_exprs bit for not removed stmts.
+
 2017-05-12  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR middle-end/69921
index 7b73b92759e860dc7d022d3e26e3de5b5f61b274..b1c69d2959407326bf35292d8b06a1ffbe0ee7bd 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80713
+       * gcc.dg/torture/pr80713.c: New testcase.
+
 2017-05-12  Andi Kleen  <ak@linux.intel.com>
 
        PR testsuite/77684
diff --git a/gcc/testsuite/gcc.dg/torture/pr80713.c b/gcc/testsuite/gcc.dg/torture/pr80713.c
new file mode 100644 (file)
index 0000000..18bd9b0
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+int a, b, d, e, f;
+int *c;
+void g()
+{
+  for (;;)
+    {
+      if (*c) {
+         int h;
+         *c = (__UINTPTR_TYPE__) &h;
+      } else
+       b = 0;
+      if (f)
+       *c = (__UINTPTR_TYPE__) g;
+      else
+       for (; a; a++)
+         for (;;) {
+             if (d)
+               break;
+             c = (int *) (__UINTPTR_TYPE__) e;
+         }
+    }
+}
index 38723df733b391f8eaed7cc4e7a3ce792d6de119..c7062b7379872b32a06be964765feb065eb444e6 100644 (file)
@@ -4947,8 +4947,14 @@ remove_dead_inserted_code (void)
        }
     }
 
+  unsigned int to_clear = -1U;
   EXECUTE_IF_SET_IN_BITMAP (inserted_exprs, 0, i, bi)
     {
+      if (to_clear != -1U)
+       {
+         bitmap_clear_bit (inserted_exprs, to_clear);
+         to_clear = -1U;
+       }
       t = SSA_NAME_DEF_STMT (ssa_name (i));
       if (!gimple_plf (t, NECESSARY))
        {
@@ -4969,7 +4975,14 @@ remove_dead_inserted_code (void)
              release_defs (t);
            }
        }
+      else
+       /* eliminate_fini will skip stmts marked for removal if we
+          already removed it and uses inserted_exprs for this, so
+          clear those we didn't end up removing.  */
+       to_clear = i;
     }
+  if (to_clear != -1U)
+    bitmap_clear_bit (inserted_exprs, to_clear);
   BITMAP_FREE (worklist);
 }