xtensa: Revise zero-call-used-regs to handle cases with no address registers.
xtensa: Fix -fzero-call-used-regs for cases where no address registers are cleared.
The xtensa implementation of -fzero-call-used-regs has been revised to correctly handle scenarios where no address registers are cleared. Previously, this could lead to a crash. The updated code now uses register A9 to clear other non-GP registers when no address registers are available, and a new test case has been added to verify this fix.
In Details
xtensa: Revise xtensa_zero_call_used_regs.
This commit revises the xtensa_zero_call_used_regs function to address a failure mode when the -fzero-call-used-regs option is enabled and no general-purpose registers are designated for zeroing. Previously, the implementation assumed at least one address register would always be cleared, and used it to zero out other non-GP registers. When this assumption was violated, a gcc_assert would trigger. The fix modifies the logic to instead zero out register A9 (which is already used in prologue/epilogue sequences) and use it for clearing other regi…
- -fzero-call-used-regs
- A compiler optimization flag that instructs the compiler to zero out registers that are not used by function calls. This can help in security scenarios by preventing information leakage from previously used registers.
- address register
- In the context of Xtensa, a register that can be used for memory addressing operations.
- non-GP register
- Registers that are not general-purpose registers, often specialized for specific tasks or floating-point operations.
- A9 register
- A specific register within the Xtensa architecture, often utilized in function prologue and epilogue sequences for various purposes.