diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp index e60f1397b993..8f3ad167ae41 100644 --- a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp +++ b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp @@ -130,7 +130,15 @@ bool WebAssemblyFrameLowering::hasReservedCallFrame( bool WebAssemblyFrameLowering::needsSPForLocalFrame( const MachineFunction &MF) const { auto &MFI = MF.getFrameInfo(); - return MFI.getStackSize() || MFI.adjustsStack() || hasFP(MF); + auto &MRI = MF.getRegInfo(); + // llvm.stacksave can explicitly read SP register and it can appear without + // dynamic alloca. + bool HasExplicitSPUse = + any_of(MRI.use_operands(getSPReg(MF)), + [](MachineOperand &MO) { return !MO.isImplicit(); }); + + return MFI.getStackSize() || MFI.adjustsStack() || hasFP(MF) || + HasExplicitSPUse; } // In function with EH pads, we need to make a copy of the value of |