This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2, i386]: Fix PR69140, stack alignment + O1 breaks with Microsoft ABI


On Wed, Jan 6, 2016 at 9:16 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

> Attached patch fixes a failure, where no base register can be found to
> save the remaining SSE (and integer) registers to stack. Since we are
> able to restore registers in the prollogue using:
>
>   m->fs.sp_valid = (!frame_pointer_needed
>    || (crtl->sp_is_unchanging
> && !stack_realign_fp));
>
> we can use similar approach at the end of the ix86_expand_prologue:
>
>   m->fs.sp_valid = !frame_pointer_needed;
>
> This way, we will always use frame pointer, if one is available or if
> frame pointer is not available, the (realigned) stack register for
> saves.
>
> 2016-01-06  Uros Bizjak  <ubizjak@gmail.com>
>
>     PR target/69140
>     * config/i386/i386.c (ix86_expand_prologue): Declare fs.sp_valid
>     depending on frame_pointer_needed before remaining integer and SSE
>     registers are saved.
>
> testsuite/ChangeLog:
>
> 2016-01-06  Uros Bizjak  <ubizjak@gmail.com>
>
>     PR target/69140
>     * gcc.target/i386/pr69140.c: New test
>
> Patch was bootstrapped and regression tested on x86_64-linux-gnu for
> all default languages, Obj-C++ and Go. The patch was also tested by
> the reporter by building and running Wine without problems.
>
> I have to admit that prologue generation is hard to test, since it has
> many different code paths. I guess committing the one-liner in the
> hope that it won't break some target is the best approach one can do.
>
> So, the patch was committed to mainline. I plan to backport it to
> gcc-5 branch after a week or two without problems in mainline.


Ouch, we can't just make %rsp valid, it doesn't point to CFA_OFFSET
when realigned. I will revert previous patch and enable frame-pointer
for realigned MS_ABI functions instead (if frame-pointer generation
is not needed, then it will be disabled in
ix86_finalize_stack_realign_flags anyway).

2016-01-07  Uros Bizjak  <ubizjak@gmail.com>

    PR target/69140
    * config/i386/i386.c (ix86_frame_pointer_required): Enable
    frame pointer for TARGET_64BIT_MS_ABI when stack is misaligned.

2016-01-07  Uros Bizjak  <ubizjak@gmail.com>

    Revert
    2016-01-06  Uros Bizjak  <ubizjak@gmail.com>

    PR target/69140
    * config/i386/i386.c (ix86_expand_prologue): Declare fs.sp_valid
    depending on frame_pointer_needed before remaining integer and SSE
    registers are saved.

Tested on x86_64-linux-gnu {,-m32}  and committed to mainline SVN.

Uros.

Attachment: p.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]