diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp @@ -21,6 +21,7 @@ #include "WebAssembly.h" #include "WebAssemblySubtarget.h" +#include "WebAssemblyMachineFunctionInfo.h" #include "llvm/CodeGen/LiveIntervals.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -83,10 +84,20 @@ for (unsigned I = 0, E = MRI.getNumVirtRegs(); I < E; ++I) { unsigned Reg = Register::index2VirtReg(I); auto &TRI = *MF.getSubtarget().getRegisterInfo(); - if (MRI.reg_nodbg_empty(Reg) || Reg == TRI.getFrameRegister(MF)) + + if (MRI.reg_nodbg_empty(Reg)) continue; LIS.splitSeparateComponents(LIS.getInterval(Reg), SplitLIs); + if (Reg == TRI.getFrameRegister(MF) && SplitLIs.size() > 0) { + // The live interval for the frame register was split, resulting in a new + // VReg. For now we only support debug info output for a single frame base + // value for the function, so just use the last one. It will certainly be + // wrong for some part of the function, but until we are able to track + // values through live-range splitting and stackification, it will have to + // do. + MF.getInfo()->setFrameBaseVreg(SplitLIs.back()->reg); + } SplitLIs.clear(); } @@ -104,5 +115,5 @@ } } - return false; + return true; }