[llvm] [WebAssembly] Define local sp if `llvm.stacksave` is used (PR #68133)

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 11:30:29 PDT 2023


================
@@ -147,7 +147,14 @@ bool WebAssemblyFrameLowering::needsPrologForEH(
 /// Unlike a machine stack pointer, the wasm user stack pointer is a global
 /// variable, so it is loaded into a register in the prolog.
 bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF) const {
-  return needsSPForLocalFrame(MF) || needsPrologForEH(MF);
+  auto &MRI = MF.getRegInfo();
+  // llvm.stacksave can explicitly read SP register and it can appear without
+  // dynamic alloca.
+  bool hasExplicitSPUse =
----------------
dschuff wrote:

Maybe this should instead go in `needsSPForLocalFrame()`? That function has other logic related to whether an SP is needed based on the current function.

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


More information about the llvm-commits mailing list