aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2021-10-25 14:00:42 -0700
committerWouter van Oortmerssen <aardappel@gmail.com>2021-11-04 11:38:03 -0700
commita320f877cec6f11e275b44ac3a239931e00b8cc8 (patch)
treed93f1d1d96f98f862ad8810509fa6e65d1a96aaa /llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
parent5de4864f74bd1ec167a77b77b99e05470f3ab578 (diff)
downloadllvm-a320f877cec6f11e275b44ac3a239931e00b8cc8.zip
llvm-a320f877cec6f11e275b44ac3a239931e00b8cc8.tar.gz
llvm-a320f877cec6f11e275b44ac3a239931e00b8cc8.tar.bz2
[WebAssembly] Fix debug locations for ExplicitLocals pass
This is a reworked version of the reverted patch: https://reviews.llvm.org/D112487 Note that a) it doesn't need the test changes anymore, and b) I checked at least locally it passes other.test_pthread_lsan_leak Differential Revision: https://reviews.llvm.org/D113208
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
index a933d1a..910a4e5 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
@@ -379,9 +379,14 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
const TargetRegisterClass *RC = MRI.getRegClass(OldReg);
Register NewReg = MRI.createVirtualRegister(RC);
unsigned Opc = getLocalGetOpcode(RC);
- InsertPt =
- BuildMI(MBB, InsertPt, MI.getDebugLoc(), TII->get(Opc), NewReg)
- .addImm(LocalId);
+ // Use a InsertPt as our DebugLoc, since MI may be discontinuous from
+ // the where this local is being inserted, causing non-linear stepping
+ // in the debugger or function entry points where variables aren't live
+ // yet. Alternative is previous instruction, but that is strictly worse
+ // since it can point at the previous statement.
+ // See crbug.com/1251909, crbug.com/1249745
+ InsertPt = BuildMI(MBB, InsertPt, InsertPt->getDebugLoc(),
+ TII->get(Opc), NewReg).addImm(LocalId);
MO.setReg(NewReg);
MFI.stackifyVReg(MRI, NewReg);
Changed = true;