]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/39118 (x86_64 red zone violation)
authorUros Bizjak <ubizjak@gmail.com>
Tue, 10 Feb 2009 16:12:47 +0000 (17:12 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 10 Feb 2009 16:12:47 +0000 (17:12 +0100)
PR target/39118
* config/i386/i386.c (expand_prologue): Emit blockage at the end
of function prologue when frame pointer is used to access
red zone area.

From-SVN: r144064

gcc/ChangeLog
gcc/config/i386/i386.c

index 547ce380331242995edcd59417b52d6a7e7d9eed..3f1c90af0463a0d2e49dad310448eb1434e4ed37 100644 (file)
@@ -1,3 +1,10 @@
+2009-02-10  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/39118
+       * config/i386/i386.c (expand_prologue): Emit blockage at the end
+       of function prologue when frame pointer is used to access
+       red zone area.
+
 2009-02-09  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/39035
index 81764671facda5522f25118d65648c7037042489..b1569f8fe5ec032e7d4c7664c1c78b7218772293 100644 (file)
@@ -6304,6 +6304,7 @@ ix86_expand_prologue (void)
 {
   rtx insn;
   bool pic_reg_used;
+  bool emit_blockage = false;
   struct ix86_frame frame;
   HOST_WIDE_INT allocate;
 
@@ -6489,9 +6490,21 @@ ix86_expand_prologue (void)
     {
       if (pic_reg_used)
        emit_insn (gen_prologue_use (pic_offset_table_rtx));
-      emit_insn (gen_blockage ());
+      emit_blockage = true;
     }
 
+  /* Prevent instructions from being scheduled into register save push
+     sequence when access to the redzone area is done through frame pointer.
+     The offset betweeh the frame pointer and the stack pointer is calculated
+     relative to the value of the stack pointer at the end of the function
+     prologue, and moving instructions that access redzone area via frame
+     pointer inside push sequence violates this assumption.  */
+  if (frame_pointer_needed && frame.red_zone_size)
+    emit_blockage = true;
+
+  if (emit_blockage)
+    emit_insn (gen_blockage ());
+
   /* Emit cld instruction if stringops are used in the function.  */
   if (TARGET_CLD && ix86_current_function_needs_cld)
     emit_insn (gen_cld ());