From patchwork Tue Jul 3 14:48:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: RFA: MEP: Fix use of delete_insn. From: Nick Clifton X-Patchwork-Id: 168836 Message-Id: <4FF30650.7010500@redhat.com> To: DJ Delorie Cc: gcc-patches@gcc.gnu.org Date: Tue, 03 Jul 2012 15:48:48 +0100 Hi DJ, > My concern is more about calling NEXT_INSN on a deleted insn. If > that's guaranteed to be "reliable", I'm OK with it. > So pick whichever solution is more future-proof and go for it :-) OK, I have gone with the following. I have replaced NEXT_INSN with next_nonnote_nondebug_insn, so that we are sure that we are dealing with a valid potential insn for removal. We do not have to worry about calling this on a deleted insn because we know that delete_insn() will only be called on a single set insn, and that deleting it will only remove that insn and not any others that follow it. Whilst doing this I noticed that follow might be set incorrectly (to a debug insn), so I fixed that as well. Cheers Nick gcc/ChangeLog 2012-07-03 Nick Clifton * config/mep/mep.c (mep_reorg_regmove): Use next_nonnote_non_debug_insn to advance to the next insn. Do not expect delete_insn to return an rtx. (insn)); @@ -5096,7 +5096,7 @@ follow, where)) { count ++; - next = delete_insn (insn); + delete_insn (insn); if (dump_file) { fprintf (dump_file, "\n----- Success! new insn:\n\n"); Index: gcc/config/mep/mep.c =================================================================== --- gcc/config/mep/mep.c (revision 189193) +++ gcc/config/mep/mep.c (working copy) @@ -5022,7 +5022,7 @@ done = 1; for (insn = insns; insn; insn = next) { - next = NEXT_INSN (insn); + next = next_nonnote_nondebug_insn (insn); if (GET_CODE (insn) != INSN) continue; pat = PATTERN (insn); @@ -5035,7 +5035,7 @@ && find_regno_note (insn, REG_DEAD, REGNO (SET_SRC (pat))) && mep_compatible_reg_class (REGNO (SET_SRC (pat)), REGNO (SET_DEST (pat)))) { - follow = next_nonnote_insn (insn); + follow = next_nonnote_nondebug_insn (insn); if (dump_file) fprintf (dump_file, "superfluous moves: considering %d\n", INSN_UID