re PR middle-end/37913 (ICE: Segmentation fault in link_block, cfg.c:153)
authorJakub Jelinek <jakub@redhat.com>
Wed, 29 Oct 2008 15:19:24 +0000 (16:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 29 Oct 2008 15:19:24 +0000 (16:19 +0100)
PR middle-end/37913
* tree-cfgcleanup.c (split_bbs_on_noreturn_calls): Only split bbs
that haven't been removed yet.

* gcc.c-torture/compile/pr37913.c: New test.

From-SVN: r141426

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr37913.c [new file with mode: 0644]
gcc/tree-cfgcleanup.c

index 643ca32594b105ab68b5217489ab7a8c8de41b7b..80e06ce896464f1552991abb664aadc60fab1b45 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/37913
+       * tree-cfgcleanup.c (split_bbs_on_noreturn_calls): Only split bbs
+       that haven't been removed yet.
+
 2008-10-29  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * config/bfin/bfin.c (struct machine_function): New member
index 14329874b01f88b378db7507670ada98079e8e59..2e23d6d4a1e0ab2016a3e1d62fea0318e8c0b072 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/37913
+       * gcc.c-torture/compile/pr37913.c: New test.
+
 2008-10-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/37663
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37913.c b/gcc/testsuite/gcc.c-torture/compile/pr37913.c
new file mode 100644 (file)
index 0000000..98b8f64
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR middle-end/37913 */
+
+void foo (void) __attribute__ ((noreturn));
+
+static int __attribute__ ((noreturn))
+bar (void)
+{
+  foo ();
+}
+
+void
+baz (void)
+{
+  int i = bar ();
+}
index 433900c3a1496beaf7bd796c8e5d76c513820c06..ba1854aae0fd359e52c2f4fdec9b30d412c2b63e 100644 (file)
@@ -483,7 +483,12 @@ split_bbs_on_noreturn_calls (void)
       {
        stmt = VEC_pop (gimple, MODIFIED_NORETURN_CALLS (cfun));
        bb = gimple_bb (stmt);
+       /* BB might be deleted at this point, so verify first
+          BB is present in the cfg.  */
        if (bb == NULL
+           || bb->index < NUM_FIXED_BLOCKS
+           || bb->index >= n_basic_blocks
+           || BASIC_BLOCK (bb->index) != bb
            || last_stmt (bb) == stmt
            || !gimple_call_noreturn_p (stmt))
          continue;