re PR tree-optimization/87693 (ICE in thread_around_empty_blocks, at tree-ssa-threade...
authorRichard Biener <rguenther@suse.de>
Tue, 23 Oct 2018 08:51:20 +0000 (08:51 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 23 Oct 2018 08:51:20 +0000 (08:51 +0000)
2018-10-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87693
* tree-ssa-threadedge.c (thread_around_empty_blocks): Handle
the case we do not find the taken edge.

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

From-SVN: r265413

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

index 0b7af4dac21ce8be6de0f8126f55945bdb8d5e85..f50070d01ca8ae8163e950869f45345a995363d7 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87693
+       * tree-ssa-threadedge.c (thread_around_empty_blocks): Handle
+       the case we do not find the taken edge.
+
 2018-10-22  Paul Koning  <ni1d@arrl.net>
 
        * symtab.c (symtab_node::increase_alignment): Correct max
index 9441c26e06dc817b4c405a2edf4bd037062cc558..204e41c94af74269021125f05b2710a101c7040c 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87693
+       * gcc.dg/torture/pr87693.c: New testcase.
+
 2018-10-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/85603
diff --git a/gcc/testsuite/gcc.dg/torture/pr87693.c b/gcc/testsuite/gcc.dg/torture/pr87693.c
new file mode 100644 (file)
index 0000000..802560d
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+void f (void);
+void g (void);
+void h (int a)
+{
+  void *p, **q;
+  if (a)
+    p = (void *)f;
+  else
+    p = (void *)g;
+  q = (void *)p;
+  if (*q == (void *)0)
+    goto *p;
+L0:
+  return;
+}
index 0b1f9733fdd3a552eb4020f1a9422f9cda2a8a5d..330ba153e3713d079db08645c47991e3f950e653 100644 (file)
@@ -981,7 +981,8 @@ thread_around_empty_blocks (edge taken_edge,
       else
        taken_edge = find_taken_edge (bb, cond);
 
-      if ((taken_edge->flags & EDGE_DFS_BACK) != 0)
+      if (!taken_edge
+         || (taken_edge->flags & EDGE_DFS_BACK) != 0)
        return false;
 
       if (bitmap_bit_p (visited, taken_edge->dest->index))