This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: DELETE_INSN() fails to delete BARRIER in some case
- From: Hiroyuki Machida <machida at sm dot sony dot co dot jp>
- To: gcc-patches at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Fri, 12 Apr 2002 20:49:08 +0900 (JST)
- Subject: Re: DELETE_INSN() fails to delete BARRIER in some case
- References: <20020405.130110.106417405.machida@sm.sony.co.jp>
Hi,
In my previous mail, attached patch is only for gcc-3.0 branch.
Here is a patch for gcc-3.1 branch.
From: Hiroyuki Machida <machida@sm.sony.co.jp>
Subject: DELETE_INSN() fails to delete BARRIER in some case
Date: Fri, 05 Apr 2002 13:01:10 +0900 (JST)
>
> Hello, all
>
> Atsushi Nemoto <nemoto@toshiba-tops.co.jp> reported the optimizer
> bug of gcc-2.95.3 for mips-linux in
> http://marc.theaimsgroup.com/?l=linux-mips&m=101788946915832&w=2
>
> I tracked down the bug and found DELETE_INSN() failed to delete
> BARRIER in some case. I think this problem potentially occures in
> any target, even in gcc-3.x.
>
> I attached a patch, bootstraped on gcc-2.95.3 for mipsel-linux.
> Please apply it to gcc-3.0, gcc-3.1 branch and HEAD.
>
> Thanks.
Index: jump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/jump.c,v
retrieving revision 1.205
diff -u -p -r1.205 jump.c
--- jump.c 21 Feb 2002 22:47:58 -0000 1.205
+++ jump.c 12 Apr 2002 05:30:38 -0000
@@ -1730,6 +1730,7 @@ delete_related_insns (insn)
int was_code_label = (GET_CODE (insn) == CODE_LABEL);
rtx note;
rtx next = NEXT_INSN (insn), prev = PREV_INSN (insn);
+ rtx next_nonote = next_nonnote_insn(insn);
while (next && INSN_DELETED_P (next))
next = NEXT_INSN (next);
@@ -1740,11 +1741,18 @@ delete_related_insns (insn)
delete_insn (insn);
- /* If instruction is followed by a barrier,
- delete the barrier too. */
+ /* If instruction is followed by a barrier, delete the barrier too.
+ In some case, there are multiple NOTEs like NOTE_INSN_BASIC_BLOCK
+ but NOTE_INSN_DELETED, between INSN and BARRIER.
+ In another case, multiple BARRIERs follow INSN.*/
- if (next != 0 && GET_CODE (next) == BARRIER)
- delete_insn (next);
+ while (next_nonote != 0 && GET_CODE (next_nonote) == BARRIER)
+ {
+ rtx barrier = next_nonote;
+ next = NEXT_INSN (barrier);
+ next_nonote = next_nonnote_insn(barrier);
+ delete_barrier (barrier);
+ }
/* If deleting a jump, decrement the count of the label,
and delete the label if it is now unused. */