From: Uros Bizjak Date: Tue, 10 Feb 2009 16:12:47 +0000 (+0100) Subject: re PR target/39118 (x86_64 red zone violation) X-Git-Tag: releases/gcc-4.3.4~340 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4964218481b30d4b8d1bc7a81236c5a4266d2f39;p=thirdparty%2Fgcc.git re PR target/39118 (x86_64 red zone violation) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 547ce3803312..3f1c90af0463 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-02-10 Uros Bizjak + + 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 PR c/39035 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 81764671facd..b1569f8fe5ec 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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 ());