[llvm] [AArch64][SME] Fix restoring callee-saves from FP with hazard padding (PR #143371)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 01:54:50 PDT 2025
================
@@ -2535,27 +2535,69 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
DeallocateAfter, TII, MachineInstr::FrameDestroy, false,
NeedsWinCFI, &HasWinCFI);
} else if (SVEStackSize) {
- // If we have stack realignment or variable sized objects on the stack,
- // restore the stack pointer from the frame pointer prior to SVE CSR
- // restoration.
- if (AFI->isStackRealigned() || MFI.hasVarSizedObjects()) {
- if (int64_t CalleeSavedSize = AFI->getSVECalleeSavedStackSize()) {
- // Set SP to start of SVE callee-save area from which they can
- // be reloaded. The code below will deallocate the stack space
- // space by moving FP -> SP.
- emitFrameOffset(MBB, RestoreBegin, DL, AArch64::SP, AArch64::FP,
- StackOffset::getScalable(-CalleeSavedSize), TII,
----------------
sdesmalen-arm wrote:
My understanding is that the only thing that is missing here is that this should have been: `StackOffset::getScalable(-CalleeSavedSize) - StackOffset::getFixed(getStackHazardSize(MF))`.
`emitFrameOffset` is written such that it takes a `StackOffset` object and should be able to [de]allocate both the fixed *and* scalable parts of the offset. If the offset is negative and consists of two components, the code doesn't correctly implement this correctly using a temporary register like you've done here. My recommendation would be to update `emitFrameOffset` to handle negative offsets properly, rather than adding that logic here for this particular case.
https://github.com/llvm/llvm-project/pull/143371
More information about the llvm-commits
mailing list