]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfgbuild.c (find_bb_boundaries): Split blocks containing a barrier.
authorDavid Daney <ddaney@caviumnetworks.com>
Thu, 3 Sep 2009 05:01:40 +0000 (05:01 +0000)
committerDavid Daney <daney@gcc.gnu.org>
Thu, 3 Sep 2009 05:01:40 +0000 (05:01 +0000)
2009-09-02  David Daney  <ddaney@caviumnetworks.com>

* cfgbuild.c (find_bb_boundaries): Split blocks containing a
barrier.
* emit-rtl.c (prev_nonnote_insn_bb): New function.
* rtl.h (prev_nonnote_insn_bb): Declare it.

2009-09-02  David Daney  <ddaney@caviumnetworks.com>

* gcc.c-torture/compile/builtin_unreachable-1.c: New testcase.

From-SVN: r151361

gcc/ChangeLog
gcc/cfgbuild.c
gcc/emit-rtl.c
gcc/rtl.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/builtin_unreachable-1.c [new file with mode: 0644]

index b0abc837876b084fb688b6d669f4c70c79e6dea5..df2129678bc385fe96e26d1edf243d610ec56619 100644 (file)
@@ -1,3 +1,10 @@
+2009-09-02  David Daney  <ddaney@caviumnetworks.com>
+
+       * cfgbuild.c (find_bb_boundaries): Split blocks containing a
+       barrier.
+       * emit-rtl.c (prev_nonnote_insn_bb): New function.
+       * rtl.h (prev_nonnote_insn_bb): Declare it.
+
 2009-09-03  Diego Novillo  <dnovillo@google.com>
 
        * cgraph.c (cgraph_node_for_decl): New.
index 012bd0b6be7ecb5bf625818096dc0e77b6f8d5af..6e941bf55e9fe5e592b9daae4cddadf52719f5db 100644 (file)
@@ -469,6 +469,13 @@ find_bb_boundaries (basic_block bb)
            make_edge (ENTRY_BLOCK_PTR, bb, 0);
        }
 
+      /* __builtin_unreachable () may cause a barrier to be emitted in
+        the middle of a BB.  We need to split it in the same manner
+        as if the barrier were preceded by a control_flow_insn_p
+        insn.  */
+      if (code == BARRIER && !flow_transfer_insn)
+       flow_transfer_insn = prev_nonnote_insn_bb (insn);
+
       /* In case we've previously seen an insn that effects a control
         flow transfer, split the block.  */
       if (flow_transfer_insn && inside_basic_block_p (insn))
index 9096a62dcbf06c8e3e558283f713a909773017af..65022fc65e31699d2ccf0d3764c146b65bf97178 100644 (file)
@@ -3082,6 +3082,25 @@ prev_nonnote_insn (rtx insn)
   return insn;
 }
 
+/* Return the previous insn before INSN that is not a NOTE, but stop
+   the search before we enter another basic block.  This routine does
+   not look inside SEQUENCEs.  */
+
+rtx
+prev_nonnote_insn_bb (rtx insn)
+{
+  while (insn)
+    {
+      insn = PREV_INSN (insn);
+      if (insn == 0 || !NOTE_P (insn))
+       break;
+      if (NOTE_INSN_BASIC_BLOCK_P (insn))
+       return NULL_RTX;
+    }
+
+  return insn;
+}
+
 /* Return the next insn after INSN that is not a DEBUG_INSN.  This
    routine does not look inside SEQUENCEs.  */
 
index 172afd0244dc4a7f37ccbe97d2ec172febc17ad1..c5839df4ecb6fe4965d89629f2c68cc5a8b1eeb4 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1675,6 +1675,7 @@ extern rtx last_call_insn (void);
 extern rtx previous_insn (rtx);
 extern rtx next_insn (rtx);
 extern rtx prev_nonnote_insn (rtx);
+extern rtx prev_nonnote_insn_bb (rtx);
 extern rtx next_nonnote_insn (rtx);
 extern rtx next_nonnote_insn_bb (rtx);
 extern rtx prev_nondebug_insn (rtx);
index 277bcc7a4de18638e88a97850b4e7cafb5e78b47..06e50502bc49940a087c76600f5b66bfb94e6c80 100644 (file)
@@ -1,3 +1,7 @@
+2009-09-02  David Daney  <ddaney@caviumnetworks.com>
+
+       * gcc.c-torture/compile/builtin_unreachable-1.c: New testcase.
+
 2009-09-03  Diego Novillo  <dnovillo@google.com>
 
        * gcc.dg/gomp/combined-1.c: Adjust expected pattern.
diff --git a/gcc/testsuite/gcc.c-torture/compile/builtin_unreachable-1.c b/gcc/testsuite/gcc.c-torture/compile/builtin_unreachable-1.c
new file mode 100644 (file)
index 0000000..dd32ca8
--- /dev/null
@@ -0,0 +1,6 @@
+void bar (const char *);
+void foo (void)
+{
+  bar ("foo");
+  __builtin_unreachable ();
+}