This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bb-reorder crashes on potential-fall-through computed jumps


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.
> If we're considering a computed branch to the next block to be fall-
> through we're wrong.

Indeed.  The problem was that mode switching had inserted the mode_set
insns between the computed jump and its barrier, and we went down the
hill from there.  Here's a patch.  Ok to install, in case it doesn't
introduce regressions on sh-elf?  Any other machine with mode
switching it would be worth testing?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* lcm.c (optimize_mode_switching): Emit mode_set before the
	JUMP_INSN of an abnormal edge.

Index: gcc/lcm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/lcm.c,v
retrieving revision 1.20
diff -u -p -r1.20 lcm.c
--- gcc/lcm.c 2001/01/05 22:06:56 1.20
+++ gcc/lcm.c 2001/02/07 12:08:04
@@ -1227,7 +1227,10 @@ optimize_mode_switching (file)
 		 previous block.  */
 	      if (eg->flags & EDGE_ABNORMAL)
 		{
-		  src_bb->end = emit_insn_after (mode_set, src_bb->end);
+		  if (GET_CODE (src_bb->end) == JUMP_INSN)
+		    emit_insn_before (mode_set, src_bb->end);
+		  else
+		    src_bb->end = emit_insn_after (mode_set, src_bb->end);
 		  bb_info[j][src_bb->index].computing = mode;
 		  RESET_BIT (transp[src_bb->index], j);
 		}

-- 
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]