x86-64 MS ABI calls: Don't preserve less registers for preserve_none
Fixes x86-64 MS ABI calls with preserve_none attribute to not incorrectly preserve registers.
This change corrects the handling of the preserve_none attribute for x86-64 calls using the MS ABI. Previously, GCC incorrectly set a flag that caused it to preserve more registers than necessary, mirroring the SYSV ABI’s behavior. This commit disables that flag for MS ABI calls, ensuring that the number of integer registers passed on the stack remains consistent with the ABI’s expectations (4 registers).
In Details
The preserve_none attribute, when applied to functions, typically influences the ABI's register save/restore behavior. For x86-64, the cum->preserve_none_abi flag historically mirrored SYSV ABI behavior regarding register passing. However, the MS ABI has a different convention for preserve_none functions, using fewer registers. This patch correctly deactivates the preserve_none_abi flag generation for MS ABI functions, harmonizing preserve_none with no_callee_saved_registers for this specific ABI and preventing unnecessary register pressure.
- preserve_none attribute
- A function attribute that suggests the function does not modify any callee-saved registers, potentially allowing for optimization.
- MS ABI
- Microsoft's Application Binary Interface, defining calling conventions and other low-level interfaces for Windows systems.
- SYSV ABI
- System V Application Binary Interface, a standard used on many Unix-like systems for defining calling conventions and other low-level interfaces.
- x86-64
- The 64-bit version of the x86 instruction set architecture, commonly used in modern desktop and server processors.