GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
x86

x86: Check argument-linked memory used for local variable

Correctly handles spilling SSA_NAMEs to argument-linked memory for local variables on x86.

This commit enhances the x86 backend’s handling of local variables passed as register arguments. It now correctly identifies and processes cases where an SSA_NAME is spilled into argument-linked memory, specifically when that memory is used to store a local variable. Previously, the compiler might incorrectly return true in such scenarios, preventing proper optimization. The change, motivated by PR target/126450, ensures more accurate register allocation and spilling by properly recognizing the usage of argument-linked memory for local variables.

In Details

This patch modifies ix86_spill_register_argument_p to correctly handle spilling of an SSA_NAME to argument-linked memory when that memory is subsequently used for a local variable. Previously, the function might have returned true for such cases, potentially misinterpreting spilled values. The change ensures that the compiler correctly identifies when argument-linked memory is repurposed as local storage, allowing for appropriate spill handling and avoiding incorrect optimization decisions. New test cases pr126450-1.c and pr126450-2.c are added.

For Context
SSA_NAME
Static Single Assignment form name. In SSA form, every variable is assigned a value only once. SSA_NAMEs are used in GCC's intermediate representation to represent these unique variable assignments, facilitating compiler optimizations.
argument-linked memory
Memory locations associated with function arguments. This can refer to stack space set aside for arguments passed by reference or where register arguments are spilled if they are not used directly for local variables.
Spilling
The process of moving values from registers to memory (typically the stack) when there are not enough registers available to hold all the live values needed at a given point in the program. This is a crucial part of register allocation.
x86 backend
The part of the GCC compiler responsible for generating machine code for the Intel x86 architecture (and its variants like x86_64).
Filed Under: x86register allocationspillingcompiler bug