]> gcc.gnu.org Git - gcc.git/commitdiff
Insert memory clobbers before the code that pops variable arrays.
authorDale Johannesen <dalej@apple.com>
Wed, 14 Aug 2002 17:41:52 +0000 (17:41 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Wed, 14 Aug 2002 17:41:52 +0000 (17:41 +0000)
This prevents the scheduler from moving references to the arrays
below the stack pop.

From-SVN: r56328

gcc/ChangeLog
gcc/doc/rtl.texi
gcc/explow.c
gcc/reload1.c

index 270fc37302422f1deb8404fa4a04268684c6831c..bb6158e06bda7782a58d0fcdb5a78d6b29d2cd3d 100644 (file)
@@ -1,3 +1,11 @@
+2002-08-14  Dale Johannesen  <dalej@apple.com>
+
+        * explow.c (emit_stack_restore):  Emit memory clobbers
+       preceding the stack pop, to prevent the scheduler from
+       moving refs to variable arrays below this pop.
+       * reload1.c (reload):  Preserve these clobbers for sched2.
+       * doc/rtl.texi:  Document clobber (mem:BLK (scratch)).
+
 2002-08-14  Neil Booth  <neil@daikokuya.co.uk>
 
        * c-opts.c (c_common_post_options): Correct test.
index 427637450ba59fc94057dba0b77c7a6434323030..8db2e9ccc6fe02d39b40d557f7af34c1e8a4eb7b 100644 (file)
@@ -2294,7 +2294,8 @@ trouble to describe the values that are stored, but it is essential to
 inform the compiler that the registers will be altered, lest it
 attempt to keep data in them across the string instruction.
 
-If @var{x} is @code{(mem:BLK (const_int 0))}, it means that all memory
+If @var{x} is @code{(mem:BLK (const_int 0))} or 
+@code{(mem:BLK (scratch))}, it means that all memory
 locations must be presumed clobbered.  If @var{x} is a @code{parallel},
 it has the same meaning as a @code{parallel} in a @code{set} expression.
 
index 1d2764064e1ee33641b4f4eaa92c95a4dae3242b..f61d009105a551fe64b39c30a07c4b1f518e15ca 100644 (file)
@@ -1079,7 +1079,17 @@ emit_stack_restore (save_level, sa, after)
     }
 
   if (sa != 0)
-    sa = validize_mem (sa);
+    {
+      sa = validize_mem (sa);
+      /* These clobbers prevent the scheduler from moving
+        references to variable arrays below the code
+        that deletes (pops) the arrays. */
+      emit_insn (gen_rtx_CLOBBER (VOIDmode,
+                   gen_rtx_MEM (BLKmode, 
+                       gen_rtx_SCRATCH (VOIDmode))));
+      emit_insn (gen_rtx_CLOBBER (VOIDmode,
+                   gen_rtx_MEM (BLKmode, stack_pointer_rtx)));
+    }
 
   if (after)
     {
index 58b0bd04bce053da881e825492fd83cdd9331744..c00426cf42013b1bd20ccdca2569cf547db9b1bc 100644 (file)
@@ -1181,9 +1181,11 @@ reload (first, global)
   /* Make a pass over all the insns and delete all USEs which we inserted
      only to tag a REG_EQUAL note on them.  Remove all REG_DEAD and REG_UNUSED
      notes.  Delete all CLOBBER insns that don't refer to the return value
-     and simplify (subreg (reg)) operands.  Also remove all REG_RETVAL and
-     REG_LIBCALL notes since they are no longer useful or accurate.  Strip
-     and regenerate REG_INC notes that may have been moved around.  */
+     or to memory (mem:BLK CLOBBERs must be retained to prevent the scheduler
+     from misarranging variable-array code) and simplify (subreg (reg))
+     operands.  Also remove all REG_RETVAL and REG_LIBCALL notes since they
+     are no longer useful or accurate.  Strip and regenerate REG_INC notes
+     that may have been moved around.  */
 
   for (insn = first; insn; insn = NEXT_INSN (insn))
     if (INSN_P (insn))
@@ -1200,6 +1202,8 @@ reload (first, global)
             && (GET_MODE (insn) == QImode
                 || find_reg_note (insn, REG_EQUAL, NULL_RTX)))
            || (GET_CODE (PATTERN (insn)) == CLOBBER
+               && (GET_CODE (XEXP (PATTERN (insn), 0)) != MEM
+                   || GET_MODE (XEXP (PATTERN (insn), 0)) != BLKmode)
                && (GET_CODE (XEXP (PATTERN (insn), 0)) != REG
                    || ! REG_FUNCTION_VALUE_P (XEXP (PATTERN (insn), 0)))))
          {
This page took 0.118147 seconds and 5 git commands to generate.