[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
Fri Jun 13 00:46:12 PDT 2025


================
@@ -2539,13 +2554,35 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
     // restore the stack pointer from the frame pointer prior to SVE CSR
     // restoration.
     if (AFI->isStackRealigned() || MFI.hasVarSizedObjects()) {
-      if (int64_t CalleeSavedSize = AFI->getSVECalleeSavedStackSize()) {
+      if (int64_t SVECalleeSavedSize = 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,
-                        MachineInstr::FrameDestroy);
+        // be reloaded.
+        const AArch64RegisterInfo *RegInfo = Subtarget.getRegisterInfo();
+        if (!AFI->isStackRealigned() && RegInfo->hasBasePointer(MF)) {
----------------
sdesmalen-arm wrote:

Can this condition just be `!AFI->isStackRealigned()` and for the code below to choose either the base register (if available) or otherwise the SP ?

https://github.com/llvm/llvm-project/pull/143371


More information about the llvm-commits mailing list