LRA now correctly marks frame pointer live when needed.
Fixed LRA to mark the frame pointer as live when it's determined to be necessary, preventing miscompiles.
This commit resolves a bug where the Late Register Allocator (LRA) might fail to mark the frame pointer as live, even when it was determined to be needed. This omission could lead to miscompilations on certain architectures like Alpha, where the frame pointer’s role in stack frame setup and restoration is critical. The fix ensures that LRA consistently treats the frame pointer as live in such scenarios, aligning its behavior with the IRA (Instruction Register Allocator) pass.
In Details
The IRA pass correctly marks the hard frame pointer register as live using df_set_regs_ever_live when frame_pointer_needed is true. However, LRA's setup_can_eliminate function could determine frame_pointer_needed later during its optimization of frame pointer to stack pointer elimination, but it failed to subsequently mark the register live. This commit adds that marking in LRA's setup_can_eliminate when frame_pointer_needed is set, ensuring LRA's frame pointer liveness decisions are consistent with IRA. This fixes a specific miscompilation on Alpha (PR117184) where an incorrectly…
- LRA
- Late Register Allocator, a compiler pass responsible for assigning physical registers to variables and temporary values after most optimizations.
- IRA
- Instruction Register Allocator, an earlier register allocation pass in GCC that operates on a lower-level intermediate representation.
- frame pointer
- A special register used to keep track of the base of the current stack frame, commonly used for accessing local variables, function arguments, and debugging.
- stack frame
- A region of memory on the call stack allocated when a function is called, used to store local variables, function arguments, and return addresses.
- df_set_regs_ever_live
- A function likely within GCC's dataflow analysis framework used to mark registers that are live (in use) at any point within a function or basic block.