Skip to content

Commit

Permalink
[WebAssembly] Fix debug locations for ExplicitLocals pass
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D112487
  • Loading branch information
aardappel committed Oct 28, 2021
1 parent f7f430c commit a66451e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
Expand Up @@ -379,8 +379,13 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
const TargetRegisterClass *RC = MRI.getRegClass(OldReg);
Register NewReg = MRI.createVirtualRegister(RC);
unsigned Opc = getLocalGetOpcode(RC);
// Use a blank DebugLoc, because InsertPt may be discontinuous from
// the usage of this value, causing non-linear stepping in the
// debugger or function entry points where variables aren't live yet.
// See crbug.com/1251909, crbug.com/1249745
DebugLoc DL;
InsertPt =
BuildMI(MBB, InsertPt, MI.getDebugLoc(), TII->get(Opc), NewReg)
BuildMI(MBB, InsertPt, DL, TII->get(Opc), NewReg)
.addImm(LocalId);
MO.setReg(NewReg);
MFI.stackifyVReg(MRI, NewReg);
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/WebAssembly/debug-localvar.ll
Expand Up @@ -101,8 +101,8 @@ attributes #2 = { nounwind }
; CHECK-NEXT: DW_AT_type (0x00000073 "int")

; CHECK-LABEL: DW_TAG_lexical_block
; CHECK-NEXT: DW_AT_low_pc (0x0000001c)
; CHECK-NEXT: DW_AT_high_pc (0x0000002d)
; CHECK-NEXT: DW_AT_low_pc (0x0000001e)
; CHECK-NEXT: DW_AT_high_pc (0x0000002f)

; CHECK-LABEL: DW_TAG_variable
; CHECK-NEXT: DW_AT_location (DW_OP_fbreg +4)
Expand Down

0 comments on commit a66451e

Please sign in to comment.