]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386/cygming: Decrease default preferred stack boundary for 32-bit targets
authorLIU Hao <lh_mouse@126.com>
Tue, 29 Apr 2025 02:43:06 +0000 (10:43 +0800)
committerJonathan Yong <10walls@gmail.com>
Sat, 10 May 2025 13:23:10 +0000 (13:23 +0000)
commitee7c0a5b70dc316477f45abc0f09dd2af9abe5cb
treef95ef8804686236ec6067d12088b4bf713ed32e9
parentab6e2d9f6f26a97e24f64a79eccbcb82b9317f82
i386/cygming: Decrease default preferred stack boundary for 32-bit targets

This commit decreases the default preferred stack boundary to 4.

In i386-options.cc, there's

   ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY;

which sets the default incoming stack boundary to this value, if it's not
overridden by other options or attributes.

Previously, GCC preferred 16-byte alignment like other platforms, unless
`-miamcu` was specified. However, the Microsoft x86 ABI only requires the
stack be aligned to 4-byte boundaries. Callback functions from MSVC code may
break this assumption by GCC (see reference below), causing local variables
to be misaligned.

For compatibility reasons, when the attribute `force_align_arg_pointer` is
attached to a function, it continues to ensure the stack is at least aligned
to a 16-byte boundary, as the documentation seems to suggest.

After this change, `STACK_REALIGN_DEFAULT` no longer has an effect on this
target, so it is removed.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111107#c9
Signed-off-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/ChangeLog:

PR target/111107
* config/i386/cygming.h (PREFERRED_STACK_BOUNDARY_DEFAULT): Override
definition from i386.h.
(STACK_REALIGN_DEFAULT): Undefine, as it no longer has an effect.
* config/i386/i386.cc (ix86_update_stack_boundary): Force minimum
128-bit alignment if `force_align_arg_pointer`.
gcc/config/i386/cygming.h
gcc/config/i386/i386.cc