From 89e99eea8015548093218f652c9d8a17e78542a3 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Fri, 29 Jan 1999 15:25:17 +0000 Subject: [PATCH] emit-rtl.c (remove_insn): New function. Fri Jan 29 18:26:07 1999 Dave Brolley * emit-rtl.c (remove_insn): New function. * rtl.h (remove_insn): Add prototype. * function.c (reposition_prologue_and_epilogue_notes): Call remove_insn. From-SVN: r24908 --- gcc/ChangeLog | 6 ++++++ gcc/emit-rtl.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/function.c | 15 +++---------- gcc/rtl.h | 1 + 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 476d746a934..af182758c50 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 29 18:26:07 1999 Dave Brolley + + * emit-rtl.c (remove_insn): New function. + * rtl.h (remove_insn): Add prototype. + * function.c (reposition_prologue_and_epilogue_notes): Call remove_insn. + Fri Jan 29 22:34:41 1999 J"orn Rennecke * loop.c (recombine_givs): Don't try to derive givs that have combined. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index d58b895e751..2e48bde2983 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -2473,6 +2473,64 @@ add_insn_before (insn, before) PREV_INSN (XVECEXP (PATTERN (before), 0, 0)) = insn; } +/* Remove an insn from its doubly-linked list. This function knows how + to handle sequences. */ +void +remove_insn (insn) + rtx insn; +{ + rtx next = NEXT_INSN (insn); + rtx prev = PREV_INSN (insn); + if (prev) + { + NEXT_INSN (prev) = next; + if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE) + { + rtx sequence = PATTERN (prev); + NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next; + } + } + else if (first_insn == insn) + first_insn = next; + else + { + struct sequence_stack *stack = sequence_stack; + /* Scan all pending sequences too. */ + for (; stack; stack = stack->next) + if (insn == stack->first) + { + stack->first = next; + break; + } + + if (stack == 0) + abort (); + } + + if (next) + { + PREV_INSN (next) = prev; + if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE) + PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev; + } + else if (last_insn == insn) + last_insn = prev; + else + { + struct sequence_stack *stack = sequence_stack; + /* Scan all pending sequences too. */ + for (; stack; stack = stack->next) + if (insn == stack->last) + { + stack->last = prev; + break; + } + + if (stack == 0) + abort (); + } +} + /* Delete all insns made since FROM. FROM becomes the new last instruction. */ diff --git a/gcc/function.c b/gcc/function.c index e2c836d6ff1..0a86580e023 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6439,7 +6439,6 @@ reposition_prologue_and_epilogue_notes (f) /* Reposition the prologue and epilogue notes. */ if (n_basic_blocks) { - rtx next, prev; int len; if (prologue) @@ -6460,6 +6459,7 @@ reposition_prologue_and_epilogue_notes (f) } else if ((len -= contains (insn, prologue)) == 0) { + rtx next; /* Find the prologue-end note if we haven't already, and move it to just after the last prologue insn. */ if (note == 0) @@ -6471,17 +6471,13 @@ reposition_prologue_and_epilogue_notes (f) } next = NEXT_INSN (note); - prev = PREV_INSN (note); - if (prev) - NEXT_INSN (prev) = next; - if (next) - PREV_INSN (next) = prev; /* Whether or not we can depend on BLOCK_HEAD, attempt to keep it up-to-date. */ if (BLOCK_HEAD (0) == note) BLOCK_HEAD (0) = next; + remove_insn (note); add_insn_after (note, insn); } } @@ -6514,12 +6510,6 @@ reposition_prologue_and_epilogue_notes (f) && NOTE_LINE_NUMBER (note) == NOTE_INSN_EPILOGUE_BEG) break; } - next = NEXT_INSN (note); - prev = PREV_INSN (note); - if (prev) - NEXT_INSN (prev) = next; - if (next) - PREV_INSN (next) = prev; /* Whether or not we can depend on BLOCK_HEAD, attempt to keep it up-to-date. */ @@ -6527,6 +6517,7 @@ reposition_prologue_and_epilogue_notes (f) && BLOCK_HEAD (n_basic_blocks-1) == insn) BLOCK_HEAD (n_basic_blocks-1) = note; + remove_insn (note); add_insn_before (note, insn); } } diff --git a/gcc/rtl.h b/gcc/rtl.h index eb9b8258649..6c2c1b3adf4 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1342,6 +1342,7 @@ extern void link_cc0_insns PROTO ((rtx)); extern void add_insn PROTO ((rtx)); extern void add_insn_before PROTO ((rtx, rtx)); extern void add_insn_after PROTO ((rtx, rtx)); +extern void remove_insn PROTO ((rtx)); extern void reorder_insns_with_line_notes PROTO ((rtx, rtx, rtx)); extern void emit_insn_after_with_line_notes PROTO ((rtx, rtx, rtx)); extern enum rtx_code classify_insn PROTO ((rtx)); -- 2.30.2