------- Comment #11 from hjl at lucon dot org  2005-10-18 18:23 -------
The change looks reasonable. I will check it out. But I still don't
like pro_epilogue_adjust_stack doesn't tell the truth about if memory is
clobbered. Why not do something like

--- gcc/config/i386/i386.c.stack        2005-10-18 10:08:25.000000000 -0700
+++ gcc/config/i386/i386.c      2005-10-18 10:11:45.000000000 -0700
@@ -4323,22 +4323,40 @@ ix86_emit_save_regs_using_mov (rtx point
    otherwise.  */

 static void
-pro_epilogue_adjust_stack (rtx dest, rtx src, rtx offset, int style)
+pro_epilogue_adjust_stack (rtx dest, rtx src, rtx offset, int style,
+                          bool clobber_memory)
 {
   rtx insn;

   if (! TARGET_64BIT)
-    insn = emit_insn (gen_pro_epilogue_adjust_stack_1 (dest, src, offset));
+    {
+      if (clobber_memory)
+       insn = emit_insn (gen_pro_epilogue_adjust_stack_1 (dest, src,
+                                                          offset));
+      else
+       insn = emit_insn (gen_addsi3 (stack_pointer_rtx,
+                                     stack_pointer_rtx, offset));
+    }
   else if (x86_64_immediate_operand (offset, DImode))
-    insn = emit_insn (gen_pro_epilogue_adjust_stack_rex64 (dest, src,
offset));+    {
+      if (clobber_memory)
+        insn = emit_insn (gen_pro_epilogue_adjust_stack_rex64 (dest,
+                                                              src,
+                                                              offset));
+      else
+       insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
+                                     stack_pointer_rtx, offset));
+    }
   else
     {
       rtx r11;
       /* r11 is used by indirect sibcall return as well, set before the
         epilogue and used after the epilogue.  ATM indirect sibcall
         shouldn't be used together with huge frame sizes in one
-        function because of the frame_size check in sibcall.c.  */
-      if (style == 0)
+        function because of the frame_size check in sibcall.c. If
+        huge frame size is used, memory should always be clobbered
+        when stack is adjusted.  */
+      if (style == 0 || !clobber_memory)
        abort ();
       r11 = gen_rtx_REG (DImode, FIRST_REX_INT_REG + 3 /* R11 */);
       insn = emit_insn (gen_rtx_SET (DImode, r11, offset));
@@ -4360,6 +4378,7 @@ ix86_expand_prologue (void)
   bool pic_reg_used;
   struct ix86_frame frame;
   HOST_WIDE_INT allocate;
+  bool using_mov;

   ix86_compute_frame_layout (&frame);

@@ -4384,7 +4403,8 @@ ix86_expand_prologue (void)

   /* When using red zone we may start register saving before allocating
      the stack frame saving one cycle of the prologue.  */
-  if (TARGET_RED_ZONE && frame.save_regs_using_mov)
+  using_mov = TARGET_RED_ZONE && frame.save_regs_using_mov;
+  if (using_mov)
     ix86_emit_save_regs_using_mov (frame_pointer_needed ?
hard_frame_pointer_rtx
                                   : stack_pointer_rtx,
                                   -frame.nregs * UNITS_PER_WORD);
@@ -4393,7 +4413,7 @@ ix86_expand_prologue (void)
     ;
   else if (! TARGET_STACK_PROBE || allocate < CHECK_STACK_LIMIT)
     pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
-                              GEN_INT (-allocate), -1);
+                              GEN_INT (-allocate), -1, !using_mov);
   else
     {
       /* Only valid for Win32.  */
@@ -4572,7 +4592,7 @@ ix86_expand_epilogue (int style)
              emit_move_insn (hard_frame_pointer_rtx, tmp);

              pro_epilogue_adjust_stack (stack_pointer_rtx, sa,
-                                        const0_rtx, style);
+                                        const0_rtx, style, true);
            }
          else
            {
@@ -4586,7 +4606,7 @@ ix86_expand_epilogue (int style)
        pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
                                   GEN_INT (frame.to_allocate
                                            + frame.nregs * UNITS_PER_WORD),
-                                  style);
+                                  style, true);
       /* If not an i386, mov & pop is faster than "leave".  */
       else if (TARGET_USE_LEAVE || optimize_size
               || !cfun->machine->use_fast_prologue_epilogue)
@@ -4595,7 +4615,7 @@ ix86_expand_epilogue (int style)
        {
          pro_epilogue_adjust_stack (stack_pointer_rtx,
                                     hard_frame_pointer_rtx,
-                                    const0_rtx, style);
+                                    const0_rtx, style, true);
          if (TARGET_64BIT)
            emit_insn (gen_popdi1 (hard_frame_pointer_rtx));
          else
@@ -4612,11 +4632,12 @@ ix86_expand_epilogue (int style)
            abort ();
          pro_epilogue_adjust_stack (stack_pointer_rtx,
                                     hard_frame_pointer_rtx,
-                                    GEN_INT (offset), style);
+                                    GEN_INT (offset), style, true);
        }
       else if (frame.to_allocate)
        pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
-                                  GEN_INT (frame.to_allocate), style);
+                                  GEN_INT (frame.to_allocate), style,
+                                  true);

       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
        if (ix86_save_reg (regno, false))


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24419

Reply via email to