This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[MIPS, committed] Fix segfault in vr4130_align_insns
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Aug 2012 17:25:21 +0100
- Subject: [MIPS, committed] Fix segfault in vr4130_align_insns
This fixes a segfault seen in the fix-vr4130* cases when run with
-O3 -mabi=64. The problem was caused by vr4130_align_insns simulating
zero-length ghost gp instructions, even though the idea is that the
scheduler should ignore them. (These instructions postdate the vr4130
stuff by quite some time.)
Tested on mips64-linux-gnu. Applied.
Richard
gcc/
* config/mips/mips.c (vr4130_align_insns): Don't simulate
ghost instructions. Assert that the required instructions exist.
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c 2012-08-27 16:28:48.068139755 +0100
+++ gcc/config/mips/mips.c 2012-08-27 16:54:59.941094052 +0100
@@ -15145,7 +15145,8 @@ vr4130_align_insns (void)
the fly to avoid a separate instruction walk. */
vr4130_avoid_branch_rt_conflict (insn);
- if (USEFUL_INSN_P (insn))
+ length = get_attr_length (insn);
+ if (length > 0 && USEFUL_INSN_P (insn))
FOR_EACH_SUBINSN (subinsn, insn)
{
mips_sim_wait_insn (&state, subinsn);
@@ -15180,6 +15181,7 @@ vr4130_align_insns (void)
issuing at the same time as the branch. We therefore
insert a nop before the branch in order to align its
delay slot. */
+ gcc_assert (last2);
emit_insn_after (gen_nop (), last2);
aligned_p = false;
}
@@ -15188,6 +15190,7 @@ vr4130_align_insns (void)
/* SUBINSN is the delay slot of INSN, but INSN is
currently unaligned. Insert a nop between
LAST and INSN to align it. */
+ gcc_assert (last);
emit_insn_after (gen_nop (), last);
aligned_p = true;
}