re PR middle-end/26983 (Missing label with builtin_setjmp/longjmp)
authorSteven Bosscher <steven@gcc.gnu.org>
Sun, 10 Sep 2006 20:08:58 +0000 (20:08 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Sun, 10 Sep 2006 20:08:58 +0000 (20:08 +0000)
PR middle-end/26983

gcc/
* builtins.c (expand_builtin_setjmp): Force next_lab to be
preserved.

testsuite/
* gcc.dg/pr26983.c: New test.

From-SVN: r116826

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr26983.c [new file with mode: 0644]

index a389b503ffa92a32db5597aa486a66b9da4a044a..c4066f353b2ccdd7454820d6b8af60cc751671b6 100644 (file)
@@ -1,3 +1,9 @@
+2006-09-10  Steven Bosscher  <steven@gcc.gnu.org>
+
+       PR middle-end/26983
+       * builtins.c (expand_builtin_setjmp): Force next_lab to be
+       preserved.
+
 2006-09-10  Richard Sandiford  <richard@codesourcery.com>
 
        PR target/29006
index 1f62dcaaf00b346e5aae7605d0c0fd56487ac25e..5bcba14d7c277365ef6a6ff804c5fb219c5cb841 100644 (file)
@@ -760,6 +760,12 @@ expand_builtin_setjmp (tree arglist, rtx target)
 
   emit_label (next_lab);
 
+  /* Because setjmp and longjmp are not represented in the CFG, a cfgcleanup
+     may find that the basic block starting with NEXT_LAB is unreachable.
+     The whole block, along with NEXT_LAB, would be removed (see PR26983).
+     Make sure that never happens.  */
+  LABEL_PRESERVE_P (next_lab) = 1;
+     
   expand_builtin_setjmp_receiver (next_lab);
 
   /* Set TARGET to one.  */
index ce2c223a640a83e866a85e6b32d83990646d254e..55eee6b150554cea8f42db828409a3aff0ce7cd2 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-10  Steven Bosscher  <steven@gcc.gnu.org>
+
+       PR middle-end/26983
+       * gcc.dg/pr26983.c: New test.
+
 2006-09-10  Richard Sandiford  <richard@codesourcery.com>
 
        PR target/29006
diff --git a/gcc/testsuite/gcc.dg/pr26983.c b/gcc/testsuite/gcc.dg/pr26983.c
new file mode 100644 (file)
index 0000000..5e2120a
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do link } */
+
+/* This used to cause a linker failure because GCC would output
+   assembler code referencing labels that it had not output.  */
+
+void *jmpbuf[6];
+
+void
+foo (void)
+{
+  __builtin_setjmp (jmpbuf);
+}
+
+int
+main (void)
+{
+  return 0;
+}
+