]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR inline-asm/6806 (gcc 3.0.4 ignoring clobbered registers in inline asm with...
authorRichard Henderson <rth@gcc.gnu.org>
Mon, 13 Sep 2004 08:54:35 +0000 (01:54 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 13 Sep 2004 08:54:35 +0000 (01:54 -0700)
        PR inline-asm/6806
        * cselib.c (cselib_invalidate_rtx): Export.  Remove unused args.
        (cselib_invalidate_rtx_note_stores): New.
        (cselib_record_sets, cselib_process_insn): Update to match.
        * cselib.h (cselib_invalidate_rtx): Declare.
        * reload1.c (reload_cse_simplify): Invalidate asm clobbers.

From-SVN: r87431

gcc/ChangeLog
gcc/cselib.c
gcc/cselib.h
gcc/reload1.c

index 0c6e389058218a0d0b6c6c4e625719b91f035bc7..05cb309f57cf2061e63455ed810d6210fc5a2164 100644 (file)
@@ -1,4 +1,13 @@
-2003-08-29  Jonathan Wakely  <redi@gcc.gnu.org>
+2004-09-13  Richard Henderson  <rth@redhat.com>
+
+        PR inline-asm/6806
+        * cselib.c (cselib_invalidate_rtx): Export.  Remove unused args.
+        (cselib_invalidate_rtx_note_stores): New.
+        (cselib_record_sets, cselib_process_insn): Update to match.
+        * cselib.h (cselib_invalidate_rtx): Declare.
+        * reload1.c (reload_cse_simplify): Invalidate asm clobbers.
+
+2004-08-29  Jonathan Wakely  <redi@gcc.gnu.org>
 
        * doc/trouble.texi (C++ misunderstandings): Fix example code.
 
index e3b228cc27d4027b0aedefd1de23520dc6b3302d..d88c6386bf7369c7b3357c8d718452dbf6c7c236 100644 (file)
@@ -63,7 +63,7 @@ static void cselib_invalidate_regno   PARAMS ((unsigned int,
 static int cselib_mem_conflict_p       PARAMS ((rtx, rtx));
 static int cselib_invalidate_mem_1     PARAMS ((void **, void *));
 static void cselib_invalidate_mem      PARAMS ((rtx));
-static void cselib_invalidate_rtx      PARAMS ((rtx, rtx, void *));
+static void cselib_invalidate_rtx_note_stores PARAMS ((rtx, rtx, void *));
 static void cselib_record_set          PARAMS ((rtx, cselib_val *,
                                                 cselib_val *));
 static void cselib_record_sets         PARAMS ((rtx));
@@ -1143,15 +1143,11 @@ cselib_invalidate_mem (mem_rtx)
   htab_traverse (hash_table, cselib_invalidate_mem_1, mem_rtx);
 }
 
-/* Invalidate DEST, which is being assigned to or clobbered.  The second and
-   the third parameter exist so that this function can be passed to
-   note_stores; they are ignored.  */
+/* Invalidate DEST, which is being assigned to or clobbered.  */
 
-static void
-cselib_invalidate_rtx (dest, ignore, data)
+void
+cselib_invalidate_rtx (dest)
      rtx dest;
-     rtx ignore ATTRIBUTE_UNUSED;
-     void *data ATTRIBUTE_UNUSED;
 {
   while (GET_CODE (dest) == STRICT_LOW_PART || GET_CODE (dest) == SIGN_EXTRACT
         || GET_CODE (dest) == ZERO_EXTRACT || GET_CODE (dest) == SUBREG)
@@ -1167,7 +1163,18 @@ cselib_invalidate_rtx (dest, ignore, data)
      invalidate the stack pointer correctly.  Note that invalidating
      the stack pointer is different from invalidating DEST.  */
   if (push_operand (dest, GET_MODE (dest)))
-    cselib_invalidate_rtx (stack_pointer_rtx, NULL_RTX, NULL);
+    cselib_invalidate_rtx (stack_pointer_rtx);
+}
+
+/* A wrapper for cselib_invalidate_rtx to be called via note_stores.  */
+
+static void
+cselib_invalidate_rtx_note_stores (dest, ignore, data)
+     rtx dest;
+     rtx ignore ATTRIBUTE_UNUSED;
+     void *data ATTRIBUTE_UNUSED;
+{
+  cselib_invalidate_rtx (dest);
 }
 
 /* Record the result of a SET instruction.  DEST is being set; the source
@@ -1293,7 +1300,7 @@ cselib_record_sets (insn)
   /* Invalidate all locations written by this insn.  Note that the elts we
      looked up in the previous loop aren't affected, just some of their
      locations may go away.  */
-  note_stores (body, cselib_invalidate_rtx, NULL);
+  note_stores (body, cselib_invalidate_rtx_note_stores, NULL);
 
   /* Now enter the equivalences in our tables.  */
   for (i = 0; i < n_sets; i++)
@@ -1358,7 +1365,7 @@ cselib_process_insn (insn)
      unlikely to help.  */
   for (x = REG_NOTES (insn); x; x = XEXP (x, 1))
     if (REG_NOTE_KIND (x) == REG_INC)
-      cselib_invalidate_rtx (XEXP (x, 0), NULL_RTX, NULL);
+      cselib_invalidate_rtx (XEXP (x, 0));
 #endif
 
   /* Look for any CLOBBERs in CALL_INSN_FUNCTION_USAGE, but only
@@ -1366,7 +1373,7 @@ cselib_process_insn (insn)
   if (GET_CODE (insn) == CALL_INSN)
     for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))
       if (GET_CODE (XEXP (x, 0)) == CLOBBER)
-       cselib_invalidate_rtx (XEXP (XEXP (x, 0), 0), NULL_RTX, NULL);
+       cselib_invalidate_rtx (XEXP (XEXP (x, 0), 0));
 
   cselib_current_insn = 0;
 
index f29ee8de04e8be6b09d7ec4c2569158d3e6e3457..877d80401dc852ba826fc57bfe8115d056d4461c 100644 (file)
@@ -68,3 +68,4 @@ extern void cselib_process_insn               PARAMS ((rtx));
 extern int rtx_equal_for_cselib_p      PARAMS ((rtx, rtx));
 extern int references_value_p          PARAMS ((rtx, int));
 extern rtx cselib_subst_to_values      PARAMS ((rtx));
+extern void cselib_invalidate_rtx      PARAMS ((rtx));
index c747ddf7297dff8fe531314994363be52820eefb..81c3fb6a8ced83bcb6fa17ebd1f634307d6b96a8 100644 (file)
@@ -8085,6 +8085,19 @@ reload_cse_simplify (insn, testreg)
       int count = 0;
       rtx value = NULL_RTX;
 
+      /* Registers mentioned in the clobber list for an asm cannot be reused
+        within the body of the asm.  Invalidate those registers now so that
+        we don't try to substitute values for them.  */
+      if (asm_noperands (body) >= 0)
+       {
+         for (i = XVECLEN (body, 0) - 1; i >= 0; --i)
+           {
+             rtx part = XVECEXP (body, 0, i);
+             if (GET_CODE (part) == CLOBBER && REG_P (XEXP (part, 0)))
+               cselib_invalidate_rtx (XEXP (part, 0));
+           }
+       }
+
       /* If every action in a PARALLEL is a noop, we can delete
         the entire PARALLEL.  */
       for (i = XVECLEN (body, 0) - 1; i >= 0; --i)