use call-clobbered reg to disalign the stack

Programming / Compilers / GCC - aoliva [138bc75d-0d04-0410-961f-82ee72b054a4] - 9 October 2019 01:14 EDT

Some x86 tests of stack realignment, that disaligned the stack with pushes and pops, failed when the compiler was configured to tune for a target that preferred to accumulate outgoing arguments: the stack space is reserved before the asm push, the call sequence overwrites the saved register, and then the asm pop restores the overwritten
value. Since that's a call-preserved register in 32-bit mode, it should be preserved unchanged, but isn't.

Merely changing the register to a call-clobbered one would be enough, but the tests would remain fragile and prone to failure due to other optimizations, so I arranged for the compiler to be made aware of the register used for the push and the pop, so it won't use it for something else, and forced the function to use a frame pointer, so that it won't use stack pointer offsets for local variables: the offsets would likely be wrong between the asm push and pop.


for gcc/testsuite/ChangeLog

- gcc.target/i386/20060512-1.c (sse2_test): Use a call-clobbered register variable for stack-disaligning push and pop. Require a frame pointer.
- gcc.target/i386/20060512-3.c (sse2_test): Likewise.

5dd1ef37022 use call-clobbered reg to disalign the stack
gcc/testsuite/ChangeLog | 7 +++++++
gcc/testsuite/gcc.target/i386/20060512-1.c | 16 +++++++++-------
gcc/testsuite/gcc.target/i386/20060512-3.c | 7 ++++---
3 files changed, 20 insertions(+), 10 deletions(-)

Upstream: gcc.gnu.org


  • Share