re PR rtl-optimization/53589 (ICE in maybe_record_trace_start with asm goto)
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Jun 2012 07:52:47 +0000 (09:52 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Jun 2012 07:52:47 +0000 (09:52 +0200)
PR rtl-optimization/53589
* cfgrtl.c (force_nonfallthru_and_redirect): Do asm_goto_edge
discovery even when e->dest != target.  If any LABEL_REF points
to e->dest label, redirect it to target's label.

* gcc.dg/torture/pr53589.c: New test.

From-SVN: r188428

gcc/ChangeLog
gcc/cfgrtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr53589.c [new file with mode: 0644]

index c2e212c42fd905a4ea0199dc2e62fc9844e23bd3..aa50728f57bde7fd2274ad9b8927ee771c2b9435 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/53589
+       * cfgrtl.c (force_nonfallthru_and_redirect): Do asm_goto_edge
+       discovery even when e->dest != target.  If any LABEL_REF points
+       to e->dest label, redirect it to target's label.
+
 2012-06-12  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * config/sh/sh.c (output_stack_adjust): Remove !epilogue_p
index 031dc259e95a93c5aa6658fa94d1dd1f635b2dea..3e4b65ec95b93b097d08be74006790da4f58f8c8 100644 (file)
@@ -1293,21 +1293,21 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
     }
 
   /* If e->src ends with asm goto, see if any of the ASM_OPERANDS_LABELs
-     don't point to target label.  */
+     don't point to the target or fallthru label.  */
   if (JUMP_P (BB_END (e->src))
       && target != EXIT_BLOCK_PTR
-      && e->dest == target
       && (e->flags & EDGE_FALLTHRU)
       && (note = extract_asm_operands (PATTERN (BB_END (e->src)))))
     {
       int i, n = ASM_OPERANDS_LABEL_LENGTH (note);
 
       for (i = 0; i < n; ++i)
-       if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (target))
-         {
+       {
+         if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (e->dest))
+           XEXP (ASM_OPERANDS_LABEL (note, i), 0) = block_label (target);
+         if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (target))
            asm_goto_edge = true;
-           break;
-         }
+       }
     }
 
   if (EDGE_COUNT (e->src->succs) >= 2 || abnormal_edge_flags || asm_goto_edge)
index 04725bd3c660a5b2e3dae42aebda24d6e599958e..2954f59f1462c01825141d7db932503e99359dd4 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/53589
+       * gcc.dg/torture/pr53589.c: New test.
+
 2012-06-12  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/50749
diff --git a/gcc/testsuite/gcc.dg/torture/pr53589.c b/gcc/testsuite/gcc.dg/torture/pr53589.c
new file mode 100644 (file)
index 0000000..5ab7890
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/53589 */
+/* { dg-do compile } */
+
+extern void foo (void) __attribute__ ((__noreturn__));
+
+void
+bar (int x)
+{
+  if (x < 0)
+    foo ();
+  if (x == 0)
+    return;
+  __asm goto ("# %l[lab]" : : : : lab);
+lab:;
+}