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.
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.  */

Reply via email to