emit-rtl.c (remove_insn): New function.
authorDave Brolley <brolley@cygnus.com>
Fri, 29 Jan 1999 15:25:17 +0000 (15:25 +0000)
committerDave Brolley <brolley@gcc.gnu.org>
Fri, 29 Jan 1999 15:25:17 +0000 (10:25 -0500)
Fri Jan 29 18:26:07 1999  Dave Brolley  <brolley@cygnus.com>
* 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
gcc/emit-rtl.c
gcc/function.c
gcc/rtl.h

index 476d746a9346306e039335e923bee7172b74a407..af182758c50b12bb2d09c2cfa5b6cad6a4424d34 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jan 29 18:26:07 1999  Dave Brolley  <brolley@cygnus.com>
+
+       * 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 <amylaar@cygnus.co.uk>
 
        * loop.c (recombine_givs): Don't try to derive givs that have combined.
index d58b895e7513c69d4a2c2c72173d46aece03a16d..2e48bde2983f10f38f79cfbbb8ec8e65a44ce67f 100644 (file)
@@ -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.  */
 
index e2c836d6ff1031d0c483f3a10b314e5c666cacf6..0a86580e02316a6655c5e8891cfa613bbf37bdcb 100644 (file)
@@ -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);
                }
            }
index eb9b8258649252f6b261143df271cb4675a40e2c..6c2c1b3adf4333f04603dfd4bb7266513fc6904a 100644 (file)
--- 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));