OK to commit?
gcc/
2009-06-16 David Daney <ddaney@caviumnetworks.com>
* jump.c (cleanup_barriers): Handle case of no insns before a
barrier.
gcc/testsuite/
2009-06-16 David Daney <ddaney@caviumnetworks.com>
* gcc.dg/builtin-unreachable-3.c: New test.
Index: gcc/testsuite/gcc.dg/builtin-unreachable-3.c
===================================================================
--- gcc/testsuite/gcc.dg/builtin-unreachable-3.c (revision 0)
+++ gcc/testsuite/gcc.dg/builtin-unreachable-3.c (revision 0)
@@ -0,0 +1,9 @@
+/* Check that a function containing only __builtin_unreachable()
+ doesn't ICE. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+const char *
+f (void)
+{
+ __builtin_unreachable ();
+}
Index: gcc/jump.c
===================================================================
--- gcc/jump.c (revision 148409)
+++ gcc/jump.c (working copy)
@@ -113,6 +113,11 @@ cleanup_barriers (void)
if (BARRIER_P (insn))
{
prev = prev_nonnote_insn (insn);
+ /* A function that contains only __builtin_unreachable() may
+ start with a barrier. In this case PREV will be
+ NULL. */
+ if (!prev)
+ continue;
if (BARRIER_P (prev))
delete_insn (insn);
else if (prev != PREV_INSN (insn))