x86: Rewrite stack alignment calculation
GCC rewrites x86 stack alignment calculation for better accuracy based on RTL points-to information.
The ix86_find_max_used_stack_alignment function in GCC’s x86 backend has been significantly rewritten. The new implementation uses RTL points-to information, fallback mechanisms involving address decomposition and memory expression checks, to more accurately determine the maximum stack slot alignment. This change aims to improve stack frame handling and corrects issues related to stack usage analysis on x86.
In Details
This commit refactors ix86_find_max_used_stack_alignment by leveraging RTL Analysis infrastructure, specifically find_base_term and static_reg_base_value, for a more robust points-to analysis of stack accesses. When RTL info is insufficient, it falls back to ix86_decompose_address and MEM_EXPR checks. The logic for updating maximum stack slot alignment is revised to only consider memory alignments whose base can be resolved to stack or frame pointers, addressing several PRs concerning stack alignment accuracy.
- RTL (Register Transfer Language)
- An intermediate representation used in GCC to describe program operations at a level between the compiler's high-level intermediate representations and the target machine code.
- points-to analysis
- A static analysis technique that determines which memory locations a pointer might refer to during program execution.
- ix86_decompose_address
- A function within GCC's x86 backend that breaks down a memory address into its base register, index, scale, and displacement components.
- MEM_EXPR
- An RTL expression representing a memory reference.
- stack alignment
- Ensuring that memory accesses to the stack are aligned to specific boundaries, which is crucial for performance and correctness on many architectures.