diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -157,6 +157,10 @@ Changed |= Old != New; UsedColors.set(Color); Assignments[Color].push_back(LI); + // If we reassigned the stack pointer, update the debug frame base info. + if (MFI.isFrameBaseVirtual() && MFI.getFrameBaseVreg() == Old) { + MFI.setFrameBaseVreg(New); + } LLVM_DEBUG(dbgs() << "Assigning vreg" << Register::virtReg2Index(LI->reg) << " to vreg" << Register::virtReg2Index(New) << "\n"); }