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 v3, i386]: Enable -mstackrealign and 'force_align_arg_pointer' attribute for x86_64


On Mon, Oct 5, 2015 at 7:33 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> As shown in PR 66697 [1] and WineHQ bug [2], an application can
>> misalign incoming stack to less than ABI mandated 16 bytes. While it
>> is possible to use -mincoming-stack-boundary=2  (= 4 bytes) for 32 bit
>> targets to emit stack realignment code, this option is artificially
>> limited to 4 (= 16  bytes) for 64bit targets.
>
> Attached v2 patch goes all the way to enable -mstackrealign and
> 'force_align_arg_pointer' attribute for x86_64. In addition to
> -mincoming-stack-boundary changes, the patch changes
> MIN_STACK_BOUNDARY definition to 8bytes on 64bit targets, as this is
> really the minimum supported stack boundary.
>
> This patch is also needed to allow stack realignment in the interrupt handler.

V3 adds support for unaligned SSE moves outside stack realignment area.

2015-10-06  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66697
    * config/i386/i386.c (ix86_option_override_internal): Always use
    8-byte minimum stack boundary in 64-bit mode.
    (ix86_compute_frame_layout): Remove assert on INCOMING_STACK_BOUNDARY.
    (ix86_emit_save_reg_using_mov): Support unaligned SSE store.
    Add a REG_CFA_EXPRESSION note if needed.
    (ix86_emit_restore_sse_regs_using_mov): Support unaligned SSE load.
    (ix86_handle_force_align_arg_pointer_attribute): New.
    (ix86_minimum_incoming_stack_boundary): Remove TARGET_64BIT check.
    (ix86_attribute_table): Set ix86_force_align_arg_pointer_string
    with ix86_handle_force_align_arg_pointer_attribute.
    * config/i386/i386.h (MIN_STACK_BOUNDARY): Set to BITS_PER_WORD.

testsuite/ChangeLog:

2015-10-06  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66697
    * gcc.target/i386/20060512-1.c: Remove ia32 requirement.
    (PUSH, POP): New defines.
    (sse2_test): Use PUSH and POP to misalign runtime stack.
    * gcc.target/i386/20060512-2.c: Remove ia32 requirement.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

An earlier version of this patch was also used to compile 64bit Wine,
where it reportedly fixes all unaligned stack failures for x86_64
target. Please see WineHQ bugreport.

I'll wait for a reconfirmation that this slightly changed patch also
works OK for Wine people, before it is committed to mainline and later
backported to gcc-5 branch.

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]