This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: bb-reorder crashes on potential-fall-through computed jumps
- To: Richard Henderson <rth at redhat dot com>
- Subject: Re: bb-reorder crashes on potential-fall-through computed jumps
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 07 Feb 2001 10:16:05 -0200
- Cc: gcc-patches at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <ork878opq8.fsf@guarana.lsd.ic.unicamp.br><20010205110931.E21066@redhat.com>
On Feb 5, 2001, Richard Henderson <rth@redhat.com> wrote:
> On Fri, Feb 02, 2001 at 05:21:35PM -0200, Alexandre Oliva wrote:
>> 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.
> That would be incorrect. Only conditional branches have fall-through.
In this case, is this ok to install? It's the same as the patch I
posted on Friday, except for the removal of computed_jump_p in the
condition to `continue;'.
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
conditional 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,8 @@ fixup_reorder_chain ()
99% case, there should not have been a fallthru edge. */
if (! e_fall)
continue;
+ if (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. */
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me