[llvm] [AMDGPU] Restore SP correctly in functions with dynamic allocas (PR #122743)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 03:09:38 PST 2025
================
@@ -525,8 +525,11 @@ Register SIRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
bool SIRegisterInfo::hasBasePointer(const MachineFunction &MF) const {
// When we need stack realignment, we can't reference off of the
// stack pointer, so we reserve a base pointer.
+ // For functions with dynamically sized stack objects, we need to reference
+ // off the base pointer in the epilog to restore the stack frame.
const MachineFrameInfo &MFI = MF.getFrameInfo();
- return MFI.getNumFixedObjects() && shouldRealignStack(MF);
+ return (MFI.getNumFixedObjects() && shouldRealignStack(MF)) ||
+ MFI.hasVarSizedObjects();
----------------
easyonaadit wrote:
> Shouldn't this required to mark BP as reserved so that regalloc won't use the specific SGPR (S34 at the moment) for allocation?
This function (hasBasePointer) is being called to decide if we should reserve BP or not. I was under the impression that this change would suffice, will something more be needed to reserve it?
https://github.com/llvm/llvm-project/pull/122743
More information about the llvm-commits
mailing list