This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix combiner cfglayout issue (PR rtl-optimization/46440)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, Paolo Bonzini <bonzini at gnu dot org>
- Date: Mon, 15 Nov 2010 21:21:08 +0100
- Subject: [PATCH] Fix combiner cfglayout issue (PR rtl-optimization/46440)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
On this testcase we ICE during flow checking, because
combiner replaced an indirect jump (which was before going into
cfglayout mode followed by BARRIER, which stays in the footer)
by direct unconditional jump. Fixed by removing the BARRIER
from the footer in that case.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Alternatively, perhaps the current_ir_type () == IR_RTL_CFGLAYOUT test
can be assumed to be 1.
2010-11-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/46440
* combine.c (update_cfg_for_uncondjump): When changing
an indirect jump into unconditional jump, remove BARRIERs
from bb's footer.
* gcc.dg/pr46440.c: New test.
--- gcc/combine.c.jj 2010-11-09 13:58:30.000000000 +0100
+++ gcc/combine.c 2010-11-15 13:53:13.000000000 +0100
@@ -2460,7 +2460,28 @@ update_cfg_for_uncondjump (rtx insn)
delete_insn (insn);
if (at_end && EDGE_COUNT (bb->succs) == 1)
- single_succ_edge (bb)->flags |= EDGE_FALLTHRU;
+ {
+ single_succ_edge (bb)->flags |= EDGE_FALLTHRU;
+
+ if (current_ir_type () == IR_RTL_CFGLAYOUT)
+ {
+ rtx insn;
+
+ /* Remove barriers from the footer if there are any. */
+ for (insn = bb->il.rtl->footer; insn; insn = NEXT_INSN (insn))
+ if (BARRIER_P (insn))
+ {
+ if (PREV_INSN (insn))
+ NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
+ else
+ bb->il.rtl->footer = NEXT_INSN (insn);
+ if (NEXT_INSN (insn))
+ PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
+ }
+ else if (LABEL_P (insn))
+ break;
+ }
+ }
}
/* Try to combine the insns I0, I1 and I2 into I3.
--- gcc/testsuite/gcc.dg/pr46440.c.jj 2010-11-15 14:12:53.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46440.c 2010-11-15 14:12:45.000000000 +0100
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/46440 */
+/* { dg-do compile } */
+/* { dg-options "-O -fstack-protector -fno-tree-dominator-opts -fno-tree-fre" } */
+/* { dg-require-effective-target fstack_protector } */
+
+int i;
+
+void bar (char *);
+
+void
+foo (void)
+{
+ void *l;
+ char c[64];
+ bar (c);
+ i = 1;
+ if (i)
+ l = &&l1;
+ else
+ l = &&l2;
+ goto *l;
+l2:
+ __builtin_abort ();
+l1:;
+}
Jakub