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

function: Honour over-alignment in stack local allocation

Ensures stack local object allocation respects required alignment beyond platform limits.

This change modifies how the compiler assigns stack space for local variables, ensuring that objects requiring alignment beyond the platform’s maximum supported stack alignment are handled correctly. It reserves extra space and performs run-time alignment, preventing issues like memory access faults on architectures like x86.

In Details

Updates assign_stack_local to correctly handle objects with alignment requirements exceeding MAX_SUPPORTED_STACK_ALIGNMENT. It introduces runtime alignment for over-aligned temporaries and locals, similar to expand_stack_vars and assign_parm_setup_block. The function assign_stack_local_2 is introduced to return the address before runtime alignment, allowing for proper alignment within reserved space. This addresses PR54412 and PR1209, where strict alignment requirements could lead to faults or incorrect memory access due to under-aligned stack slots.

For Context
MAX_SUPPORTED_STACK_ALIGNMENT
A backend-defined limit on the maximum alignment that can be guaranteed for stack-allocated variables. Some targets cap this at 128 bits.
assign_stack_local
A compiler internal function responsible for allocating space and determining the address for local variables on the call stack.
RTL
Register Transfer Language. An intermediate representation used internally by GCC to represent code before it is optimized and translated into machine code.
VIRTUAL_STACK_VARS_REGNUM
A special register number used internally by GCC to represent the base address of the stack frame for virtual stack variables.
SJLJ exception handling
Setjmp/Longjmp exception handling. A method for implementing exceptions that relies on stack manipulation rather than a dedicated runtime library.
Filed Under: optimizationstack alignmentx86aarch64