re PR middle-end/45458 (ICE: in add_labels_and_missing_jumps, at bb-reorder.c:1306...
authorJakub Jelinek <jakub@redhat.com>
Wed, 1 Sep 2010 19:46:21 +0000 (21:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 1 Sep 2010 19:46:21 +0000 (21:46 +0200)
PR middle-end/45458
* bb-reorder.c (add_labels_and_missing_jumps): Treat
bbs ending with throwing insns like blocks ending with a call.
(fix_up_fall_thru_edges): Likewise.

* g++.dg/tree-prof/partition2.C: New test.

From-SVN: r163743

gcc/ChangeLog
gcc/bb-reorder.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-prof/partition2.C [new file with mode: 0644]

index 10ea824900403c5f8a4c2dfc8f8404c4aae6f356..077c6fb42dd82c155f5724456605de0cd6a45baa 100644 (file)
@@ -1,3 +1,10 @@
+2010-09-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45458
+       * bb-reorder.c (add_labels_and_missing_jumps): Treat
+       bbs ending with throwing insns like blocks ending with a call.
+       (fix_up_fall_thru_edges): Likewise.
+
 2010-09-01  Nathan Froyd  <froydnj@codesourcery.com>
 
        * config/m32c/m32c-protos.h (m32c_function_arg): Delete.
index 2bf0b8531658bc85ad7ac140583bc1aba3b26164..e4996144761a575be66ff98ad6e75d71a7ba2f9b 100644 (file)
@@ -1299,7 +1299,9 @@ add_labels_and_missing_jumps (edge *crossing_edges, int n_crossing_edges)
 
              if (src && (src != ENTRY_BLOCK_PTR))
                {
-                 if (!JUMP_P (BB_END (src)) && !block_ends_with_call_p (src))
+                 if (!JUMP_P (BB_END (src))
+                     && !block_ends_with_call_p (src)
+                     && !can_throw_internal (BB_END (src)))
                    /* bb just falls through.  */
                    {
                      /* make sure there's only one successor */
@@ -1316,9 +1318,9 @@ add_labels_and_missing_jumps (edge *crossing_edges, int n_crossing_edges)
                      src->il.rtl->footer = unlink_insn_chain (barrier, barrier);
                      /* Mark edge as non-fallthru.  */
                      crossing_edges[i]->flags &= ~EDGE_FALLTHRU;
-                   } /* end: 'if (GET_CODE ... '  */
-               } /* end: 'if (src && src->index...'  */
-           } /* end: 'if (dest && dest->index...'  */
+                   } /* end: 'if (!JUMP_P ... '  */
+               } /* end: 'if (src && src !=...'  */
+           } /* end: 'if (dest && dest !=...'  */
        } /* end: 'if (crossing_edges[i]...'  */
     } /* end for loop  */
 }
@@ -1375,19 +1377,21 @@ fix_up_fall_thru_edges (void)
          fall_thru = succ2;
          cond_jump = succ1;
        }
-      else if (!fall_thru && succ1 && block_ends_with_call_p (cur_bb))
-      {
-        edge e;
-        edge_iterator ei;
-
-        /* Find EDGE_CAN_FALLTHRU edge.  */
-        FOR_EACH_EDGE (e, ei, cur_bb->succs)
-          if (e->flags & EDGE_CAN_FALLTHRU)
-          {
-            fall_thru = e;
-            break;
-          }
-      }
+      else if (succ1
+              && (block_ends_with_call_p (cur_bb)
+                  || can_throw_internal (BB_END (cur_bb))))
+       {
+         edge e;
+         edge_iterator ei;
+
+         /* Find EDGE_CAN_FALLTHRU edge.  */
+         FOR_EACH_EDGE (e, ei, cur_bb->succs)
+           if (e->flags & EDGE_CAN_FALLTHRU)
+             {
+               fall_thru = e;
+               break;
+             }
+       }
 
       if (fall_thru && (fall_thru->dest != EXIT_BLOCK_PTR))
        {
index 67f5a20cfa091e36816d9254b9bfe2ee1a1e53ab..fbe877c6de7911f89e2c64ac4bb48b773a47b722 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/45458
+       * g++.dg/tree-prof/partition2.C: New test.
+
 2010-09-01  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/vect/vect-outer-fir.c: Adjust.
diff --git a/gcc/testsuite/g++.dg/tree-prof/partition2.C b/gcc/testsuite/g++.dg/tree-prof/partition2.C
new file mode 100644 (file)
index 0000000..ca5671f
--- /dev/null
@@ -0,0 +1,15 @@
+// PR middle-end/45458
+// { dg-require-effective-target freorder }
+// { dg-options "-fnon-call-exceptions -freorder-blocks-and-partition" }
+
+int
+main ()
+{
+  try
+  {
+    throw 6;
+  }
+  catch (...)
+  {
+  }
+}