diff mbox

[i386] : Unbreak bootstrap for x64 SEH enabled target

Message ID CAEwic4YeLg3_oPmijLcahkXqjvrJB3cuZ5PRo1mMMBWnsTKrQg@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Oct. 12, 2011, 7:07 a.m. UTC
Hello,

by recent changes gcc begun to move code into the prologue region.
This is for x64 SEH an issue, as here the table-information for
prologue is limited to 255 bytes size.  So we need to avoid moving
additional code into prologue.  To achieve this we mark all standard
and xmm registers as prologue-used at the end of prologue.   Also we
need to emit a memory blockage.

ChangeLog

2011-10-12  Kai Tietz  <ktietz@redhat.com>

        * config/i386/i386.c (ix86_expand_prologue): Mark
        for TARGET_SEH all sse/integer registers as prologue-used.

Tested for x86_64-w64-mingw32.  Ok for apply?

Regards,
Kai

Comments

Richard Henderson Oct. 12, 2011, 3:58 p.m. UTC | #1
On 10/12/2011 12:07 AM, Kai Tietz wrote:
> Hello,
> 
> by recent changes gcc begun to move code into the prologue region.
> This is for x64 SEH an issue, as here the table-information for
> prologue is limited to 255 bytes size.  So we need to avoid moving
> additional code into prologue.  To achieve this we mark all standard
> and xmm registers as prologue-used at the end of prologue.   Also we
> need to emit a memory blockage.
> 
> ChangeLog
> 
> 2011-10-12  Kai Tietz  <ktietz@redhat.com>
> 
>         * config/i386/i386.c (ix86_expand_prologue): Mark
>         for TARGET_SEH all sse/integer registers as prologue-used.
> 
> Tested for x86_64-w64-mingw32.  Ok for apply?
> 
> Regards,
> Kai
> 
> Index: i386.c
> ===================================================================
> --- i386.c      (revision 179824)
> +++ i386.c      (working copy)
> @@ -10356,7 +10356,24 @@
>       Further, prevent alloca modifications to the stack pointer from being
>       combined with prologue modifications.  */
>    if (TARGET_SEH)
> -    emit_insn (gen_prologue_use (stack_pointer_rtx));
> +    {
> +      int i;
> +
> +      /* Due limited size of prologue-code size of 255 bytes,
> +         we need to prevent scheduler to sink instructions into
> +         prologue code.  Therefore we mark all standard, sse, fpu,
> +         and the pc registers as prologue-used to prevent this.
> +         Also an memory-blockage is necessary.  */
> +      emit_insn (gen_memory_blockage ());
> +
> +      for (i = 0; i <= 7; i++)
> +        {
> +         emit_insn (gen_prologue_use (gen_rtx_REG (Pmode, AX_REG + i)));
> +         emit_insn (gen_prologue_use (gen_rtx_REG (Pmode, R8_REG + i)));
> +         emit_insn (gen_prologue_use (gen_rtx_REG (TImode, XMM0_REG + i)));
> +         emit_insn (gen_prologue_use (gen_rtx_REG (TImode, XMM8_REG + i)));
> +       }
> +    }

This is overkill.  We simply need to disable shrink-wrapping for SEH.
The easiest way to do that is to add !TARGET_SEH (and a comment) to
the simple_return pattern predicate.


r~
diff mbox

Patch

Index: i386.c
===================================================================
--- i386.c      (revision 179824)
+++ i386.c      (working copy)
@@ -10356,7 +10356,24 @@ 
      Further, prevent alloca modifications to the stack pointer from being
      combined with prologue modifications.  */
   if (TARGET_SEH)
-    emit_insn (gen_prologue_use (stack_pointer_rtx));
+    {
+      int i;
+
+      /* Due limited size of prologue-code size of 255 bytes,
+         we need to prevent scheduler to sink instructions into
+         prologue code.  Therefore we mark all standard, sse, fpu,
+         and the pc registers as prologue-used to prevent this.
+         Also an memory-blockage is necessary.  */
+      emit_insn (gen_memory_blockage ());
+
+      for (i = 0; i <= 7; i++)
+        {
+         emit_insn (gen_prologue_use (gen_rtx_REG (Pmode, AX_REG + i)));
+         emit_insn (gen_prologue_use (gen_rtx_REG (Pmode, R8_REG + i)));
+         emit_insn (gen_prologue_use (gen_rtx_REG (TImode, XMM0_REG + i)));
+         emit_insn (gen_prologue_use (gen_rtx_REG (TImode, XMM8_REG + i)));
+       }
+    }
 }

 /* Emit code to restore REG using a POP insn.  */