[PATCH] D72969: [WebAssembly] Track frame registers through VReg and local allocation
Derek Schuff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 17:05:16 PST 2020
dschuff created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, hiraditya, jgravelle-google, sbc100, aprantl, MatzeB.
Herald added a project: LLVM.
This change has 2 components:
Target-independent: add a method getDwarfFrameBase to TargetFrameLowering. It
describes how the Dwarf frame base will be encoded. That can be a register (the
default), the CFA (which replaces NVPTX-specific logic in DwarfCompileUnit), or
a DW_OP_WASM_location descriptr.
WebAssembly: Allow WebAssemblyFunctionInfo::getFrameRegister to return the
correct virtual register instead of FP32/SP32 after WebAssemblyReplacePhysRegs
has run. Make WebAssemblyExplicitLocals store the local it allocates for the
frame register. Use this local information to implement getDwarfFrameBase
The result is that the DW_AT_frame_base attribute is correctly encoded for each
subprogram, and each param and local variable has a correct DW_AT_location that
uses DW_OP_fbreg to refer to the frame base.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72969
Files:
llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp
Index: llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp
+++ 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<WebAssemblySubtarget>().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<WebAssemblyFunctionInfo>()->setFrameBaseVreg(SplitLIs.back()->reg);
+ }
SplitLIs.clear();
}
@@ -104,5 +115,5 @@
}
}
- return false;
+ return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72969.238931.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200118/5409427b/attachment-0001.bin>
More information about the llvm-commits
mailing list