diff mbox

[i386] : Fix recent bootstrap failure for x86_64 windows target

Message ID CAEwic4aF+HOtKh4w3nPmTYtGSSYosg6rwOarc5SLKjCj_6ckJw@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Aug. 4, 2011, 8:53 p.m. UTC
Hello,

recently we got a bootstrap failure in libfortran's transfer.c:sset
function.  This is caused by optimizing alloca into prologue.  This
can cause for x64 with SEH to too large prologue-frame-size for SEH
information.
This patch simply assumes that iff the function is using an alloca
call, then we should set frame's hard_frame_pointer_offset to its
current  stack_pointer_offset (minus 128 delta for smaller common
stack-address ranges).

ChangeLog

2011-08-04  Kai Tietz  <ktietz@redhat.com>

        * config/i386/i386.c (ix86_compute_frame_layout): Adjust
hard_frame_pointer_offset
        if function uses alloca.

Regression test in progress. Ok for apply after successful test?

Regards,
Kai

Comments

Richard Henderson Aug. 4, 2011, 9:05 p.m. UTC | #1
On 08/04/2011 01:53 PM, Kai Tietz wrote:
>        diff = frame->stack_pointer_offset - frame->hard_frame_pointer_offset;
> -      if (diff > 240 || (diff & 15) != 0)
> +      if (diff > 240 || (diff & 15) != 0 || cfun->calls_alloca != 0)

Hmm.  Why didn't the diff > 240 test trigger?


r~
Kai Tietz Aug. 4, 2011, 9:10 p.m. UTC | #2
2011/8/4 Richard Henderson <rth@redhat.com>:
> On 08/04/2011 01:53 PM, Kai Tietz wrote:
>>        diff = frame->stack_pointer_offset - frame->hard_frame_pointer_offset;
>> -      if (diff > 240 || (diff & 15) != 0)
>> +      if (diff > 240 || (diff & 15) != 0 || cfun->calls_alloca != 0)
>
> Hmm.  Why didn't the diff > 240 test trigger?

The point seems to be that the alloca block gets added later to rsp,
but prologue is already layout, so it thinks it could use complete
frame-size.  But due limitation of frame-size in SEH information to
240 bytes, this causes an assert in winnt.c:821

Not sure if this is not more a paper-patch for another underlying
issue, but it seems to work so far.

Regards,
Kai

PS: I sent you reduced test (from gfortran's transfer.c (sset) offlist
Kai Tietz Aug. 5, 2011, 8 a.m. UTC | #3
2011/8/4 Kai Tietz <ktietz70@googlemail.com>:
> 2011/8/4 Richard Henderson <rth@redhat.com>:
>> On 08/04/2011 01:53 PM, Kai Tietz wrote:
>>>        diff = frame->stack_pointer_offset - frame->hard_frame_pointer_offset;
>>> -      if (diff > 240 || (diff & 15) != 0)
>>> +      if (diff > 240 || (diff & 15) != 0 || cfun->calls_alloca != 0)
>>
>> Hmm.  Why didn't the diff > 240 test trigger?
>
> The point seems to be that the alloca block gets added later to rsp,
> but prologue is already layout, so it thinks it could use complete
> frame-size.  But due limitation of frame-size in SEH information to
> 240 bytes, this causes an assert in winnt.c:821
>
> Not sure if this is not more a paper-patch for another underlying
> issue, but it seems to work so far.

It seems not to be the proper fix.  The issue seems to be caused
somewhere else.  This patch fixed some testcases, but shows others
failing due it.

Kai
diff mbox

Patch

Index: i386.c
===================================================================
--- i386.c      (revision 177412)
+++ i386.c      (working copy)
@@ -8860,7 +8860,7 @@ 

       /* If we can leave the frame pointer where it is, do so.  */
       diff = frame->stack_pointer_offset - frame->hard_frame_pointer_offset;
-      if (diff > 240 || (diff & 15) != 0)
+      if (diff > 240 || (diff & 15) != 0 || cfun->calls_alloca != 0)
        {
          /* Ideally we'd determine what portion of the local stack frame
             (within the constraint of the lowest 240) is most heavily used.