[llvm] [AMDGPU] Make chain functions receive a stack pointer (PR #184616)

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 02:01:32 PST 2026


================
@@ -1216,33 +1216,24 @@ void SIFrameLowering::emitPrologue(MachineFunction &MF,
   // to determine the end of the prologue.
   DebugLoc DL;
 
-  if (FuncInfo->isChainFunction()) {
-    // Functions with the amdgpu_cs_chain[_preserve] CC don't receive a SP, but
-    // are free to set one up if they need it.
-    bool UseSP = requiresStackPointerReference(MF);
-    if (UseSP) {
-      assert(StackPtrReg != AMDGPU::SP_REG);
-
-      BuildMI(MBB, MBBI, DL, TII->get(AMDGPU::S_MOV_B32), StackPtrReg)
-          .addImm(MFI.getStackSize() * getScratchScaleFactor(ST));
-    }
-  }
-
   bool HasFP = false;
   bool HasBP = false;
   uint32_t NumBytes = MFI.getStackSize();
   uint32_t RoundedSize = NumBytes;
 
+  // Chain functions never return, so there's no need to save and restore the FP
+  // or BP.
+  bool SavesStackRegs = !FuncInfo->isChainFunction();
----------------
rovka wrote:

I think so, I'll have a look. Thanks!

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


More information about the llvm-commits mailing list