x86-64: Use R11 for DRAP register in preserve_none functions
The compiler now uses R11 for the DRAP register in preserve_none functions on x86-64, improving stack alignment.
This commit changes the register used for the DRAP (dynamic realignment argument pointer) in preserve_none functions on x86-64 from R10 to R11. R11 is a more suitable choice because it doesn’t conflict with argument registers. This change ensures proper stack pointer restoration in function epilogues after stack realignment, and includes new test cases for verification.
In Details
This commit modifies ix86_save_reg and find_drap_reg in config/i386/i386.cc to use R11 for the DRAP register in preserve_none functions in 64-bit mode. The DRAP register is used during stack realignment to restore the stack pointer. This change avoids conflicts with registers used for parameter passing, specifically R10. The patch also introduces pr120870-1.c and pr120870-2.c in gcc.target/i386/ to validate the fix.
For Context
The x86-64 architecture requires proper stack alignment for certain operations. The DRAP register is used to restore the stack pointer after stack realignment. preserve_none functions are functions that do not preserve any registers. This commit ensures that the compiler uses a register that doesn't conflict with argument passing when restoring the stack pointer in these functions, preventing potential issues with stack alignment and function behavior. Stack alignment is important for performance.