diff mbox

[ARM] Fix segfault in thumb1_reorg

Message ID 537A316E.6060405@arm.com
State New
Headers show

Commit Message

Richard Earnshaw May 19, 2014, 4:29 p.m. UTC
A fault in thumb1_reorg means we can try to get the insn_code of
something that isn't an insn.  This appears to be a latent problem
that's suddenly started to bite on trunk.  The code in question appears
to go back to gcc-4.8.

RTL checking would probably have found this quickly, but that's very
expensive so not normally enabled during trunk development.

Anyway, the fix is simple, when looking backwards for a jump insn, skip
anything that's not a proper insn: ie anything that's not both an insn
and not a debugging insn.

I expect to also be needed on 4.8 and 4.9, since I can see no obvious
reason why it doesn't happen there as well.  I've already done 4.9, but
4.8 can wait for now as the code is very slightly different there and
would benefit from further testing.

	* arm.c (thumb1_reorg): When scanning backwards skip anything
	that's not a proper insn.

Applied to 4.9 and trunk.

R.

Comments

Eric Botcazou May 21, 2014, 8:47 a.m. UTC | #1
> RTL checking would probably have found this quickly, but that's very
> expensive so not normally enabled during trunk development.

This used to be very expensive, but has been only moderately expensive for a 
while (it's in my checking options for years on trunk for x86/x86-64).
diff mbox

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 1e44080..5e5256d 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -16934,7 +16934,7 @@  thumb1_reorg (void)
       rtx prev, insn = BB_END (bb);
       bool insn_clobbered = false;
 
-      while (insn != BB_HEAD (bb) && DEBUG_INSN_P (insn))
+      while (insn != BB_HEAD (bb) && !NONDEBUG_INSN_P (insn))
 	insn = PREV_INSN (insn);
 
       /* Find the last cbranchsi4_insn in basic block BB.  */