Fix sigsegv in find_same_succ_bb
authorTom de Vries <tom@codesourcery.com>
Mon, 3 Jul 2017 07:20:49 +0000 (07:20 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 3 Jul 2017 07:20:49 +0000 (07:20 +0000)
2017-07-03  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/81192
* tree-ssa-tail-merge.c (same_succ_flush_bb): Handle
BB_SAME_SUCC (bb) == NULL.

* gcc.dg/pr81192.c: New test.

From-SVN: r249893

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr81192.c [new file with mode: 0644]
gcc/tree-ssa-tail-merge.c

index 64793d9a95f4145ed58b86b075b6c5bc6316c23d..7284fef28063acdaea6b9ca34097b4868ea31dbd 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-03  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/81192
+       * tree-ssa-tail-merge.c (same_succ_flush_bb): Handle
+       BB_SAME_SUCC (bb) == NULL.
+
 2017-07-02  Jan Hubicka  <hubicka@ucw.cz>
 
        * cfgrtl.c (rtl_verify_edges): Enable checking of profile_probability
index ac9c6a63d6170b43e14b5c3c83292e69d86d74c2..dda405aa9e7277860b7a7478096a7776c9366bdc 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-03  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/81192
+       * gcc.dg/pr81192.c: New test.
+
 2017-07-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        * gfortran/eoshift_3.f90:  New test.
diff --git a/gcc/testsuite/gcc.dg/pr81192.c b/gcc/testsuite/gcc.dg/pr81192.c
new file mode 100644 (file)
index 0000000..57eb478
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-options "-Os -fdump-tree-pre-details" } */
+
+unsigned a;
+int b, c;
+
+static int
+fn1 (int p1, int p2)
+{
+  return p1 > 2147483647 - p2 ? p1 : p1 + p2;
+}
+
+void
+fn2 (void)
+{
+  int j;
+  a = 30;
+  for (; a;)
+    for (; c; b = fn1 (j, 1))
+      ;
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)find_duplicates: <bb .*> duplicate of <bb .*>" 1 "pre" } } */
index db836f7187f848d826070082f391dbd4f53da76b..e88072c1836799ca2d6358060b7006a27e3f31bc 100644 (file)
@@ -809,6 +809,9 @@ static void
 same_succ_flush_bb (basic_block bb)
 {
   same_succ *same = BB_SAME_SUCC (bb);
+  if (! same)
+    return;
+
   BB_SAME_SUCC (bb) = NULL;
   if (bitmap_single_bit_set_p (same->bbs))
     same_succ_htab->remove_elt_with_hash (same, same->hashval);