[PATCH] D78218: [LiveDebugValues] Terminate open ranges on DBG_VALUE $noreg
Jeremy Morse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 09:50:48 PDT 2020
jmorse created this revision.
jmorse added reviewers: djtodoro, TWeaver, aprantl, vsk.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
In D68209 <https://reviews.llvm.org/D68209>, LiveDebugValues::transferDebugValue had a call to OpenRanges.erase shifted, and by accident this led to a code path where DBG_VALUEs of $noreg would not have their open range terminated, allowing variable locations to extend past blocks where they were terminated.
This patch correctly terminates the open range, if present, when such a DBG_VAUE is encountered, and add a test for this behaviour.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78218
Files:
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_terminated.mir
Index: llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_terminated.mir
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_terminated.mir
@@ -0,0 +1,67 @@
+--- |
+ ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE
+
+ ; Check that DBG_VALUE instructions are not propagated into a loop that
+ ; explicitly termiantes its location.
+
+ ; CHECK: ![[VARNO:[0-9]+]] = !DILocalVariable(name: "myVar"
+ ; CHECK-LABEL: bb.0.entry:
+ ; CHECK: DBG_VALUE $ebx, $noreg, ![[VARNO]], !DIExpression(),
+ ; CHECK-LABEL: bb.2.bb2:
+ ; CHECK: DBG_VALUE $noreg, $noreg, ![[VARNO]], !DIExpression(),
+
+ define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
+ entry:
+ br label %bb1, !dbg !17
+ bb1:
+ br label %bb2, !dbg !17
+ bb2:
+ br label %bb3, !dbg !17
+ bb3:
+ ret i32 0, !dbg !17
+ }
+
+ !llvm.dbg.cu = !{!0}
+ !llvm.module.flags = !{!7, !8, !9, !10}
+ !llvm.ident = !{!11}
+ !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None)
+ !1 = !DIFile(filename: "main.cpp", directory: "F:\test")
+ !2 = !{}
+ !3 = !{!4}
+ !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
+ !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
+ !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+ !7 = !{i32 2, !"Dwarf Version", i32 4}
+ !8 = !{i32 2, !"Debug Info Version", i32 3}
+ !9 = !{i32 1, !"wchar_size", i32 2}
+ !10 = !{i32 7, !"PIC Level", i32 2}
+ !11 = !{!"clang version 10.0.0"}
+ !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
+ !13 = !DISubroutineType(types: !14)
+ !14 = !{!6, !6}
+ !15 = !{!16}
+ !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
+ !17 = !DILocation(line: 10, scope: !12)
+
+...
+---
+name: _Z8bb_to_bb
+body: |
+ bb.0.entry:
+ successors: %bb.1
+ $ebx = MOV32ri 0, debug-location !17
+ DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+
+ bb.1.bb1:
+ successors: %bb.2
+ $eax = MOV32ri 0, debug-location !17
+
+ bb.2.bb2:
+ successors: %bb.1, %bb.3
+ $ecx = MOV32ri 1, debug-location !17
+ DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17
+ JCC_1 %bb.1, 4, implicit killed $eflags
+
+ bb.3.bb3:
+ RETQ $eax, debug-location !17
+...
Index: llvm/lib/CodeGen/LiveDebugValues.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugValues.cpp
+++ llvm/lib/CodeGen/LiveDebugValues.cpp
@@ -947,9 +947,11 @@
} else if (MI.hasOneMemOperand()) {
llvm_unreachable("DBG_VALUE with mem operand encountered after regalloc?");
} else {
- // This must be an undefined location. We should leave OpenRanges closed.
+ // This must be an undefined location. If it has an open range, erase it.
assert(MI.getOperand(0).isReg() && MI.getOperand(0).getReg() == 0 &&
"Unexpected non-undef DBG_VALUE encountered");
+ VarLoc VL(MI, LS);
+ OpenRanges.erase(VL);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78218.257753.patch
Type: text/x-patch
Size: 3507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/fcb66356/attachment.bin>
More information about the llvm-commits
mailing list