This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
bb-reorder crashes on potential-fall-through computed jumps
- To: gcc-patches at gcc dot gnu dot org
- Subject: bb-reorder crashes on potential-fall-through computed jumps
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 02 Feb 2001 17:21:35 -0200
- Organization: GCC Team, Red Hat
gcc.c-torture/compile/950613-1.c fails on SH with -m4 -O2. The
problem is that the subsequent basic block is indeed one of the
potential edges, so the jump is considered as a potential
fall-through, so we end up crashing.
Here's a patch that arranges for us not to abort() on non-conditional
and conditional computed jumps (the latter was needed by another port
I have worked on, so I'm taking the opportunity to contribute the
code).
Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* jump.c (any_cond_computed_jump_p): New.
* bb-reorder.c (fixup_reorder_chain): Don't crash on computed
jumps.
Index: gcc/jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.152
diff -u -p -r1.152 jump.c
--- gcc/jump.c 2001/01/30 19:34:40 1.152
+++ gcc/jump.c 2001/02/02 19:10:36
@@ -2304,6 +2304,32 @@ any_condjump_p (insn)
|| (a == PC && (b == LABEL_REF || b == RETURN)));
}
+/* Return true when insn is a conditional jump to a register. This
+ function works for instructions containing PC sets in PARALLELs.
+ The instruction may have various other effects so before removing
+ the jump you must verify onlyjump_p.
+
+ Note that unlike condjump_p it returns false for unconditional jumps. */
+
+int
+any_cond_computed_jump_p (insn)
+ rtx insn;
+{
+ rtx x = pc_set (insn);
+ enum rtx_code a, b;
+
+ if (!x)
+ return 0;
+ if (GET_CODE (SET_SRC (x)) != IF_THEN_ELSE)
+ return 0;
+
+ a = GET_CODE (XEXP (SET_SRC (x), 1));
+ b = GET_CODE (XEXP (SET_SRC (x), 2));
+
+ return ((b == PC && a == REG)
+ || (a == PC && b == REG));
+}
+
/* Return the label of a conditional jump. */
rtx
Index: gcc/bb-reorder.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/bb-reorder.c,v
retrieving revision 1.25
diff -u -p -r1.25 bb-reorder.c
--- gcc/bb-reorder.c 2001/01/24 05:57:46 1.25
+++ gcc/bb-reorder.c 2001/02/02 19:10:37
@@ -638,6 +638,9 @@ fixup_reorder_chain ()
99% case, there should not have been a fallthru edge. */
if (! e_fall)
continue;
+ if (computed_jump_p (bb_end_insn)
+ || any_cond_computed_jump_p (bb_end_insn))
+ continue;
#ifdef CASE_DROPS_THROUGH
/* Except for VAX. Since we didn't have predication for the
tablejump, the fallthru block should not have moved. */