Skip to content

Commit f514776

Browse files
Tom WeaverTom Weaver
authored andcommitted
[DebugInfo][LiveDebugValues] Teach Live Debug Values About Meta Instructions
Previously LiveDebugValues pass would consider meta instructions that 'fiddle' with liveness of registers as register definitions when transfering register defs. This would mean that, for example, a KILL instruction would cause LiveDebugValues to terminate the range of an earlier DBG_VALUE instruction resulting in the none propogation of said DBG_VALUE instructions into later blocks. This patch adds the check and a helpful comment, fixes a test that previously tested for the broken behaviour by coincidence and adds a test specifically for this. reviewers: vsk, dstenb, djtodoro Differential Revision: https://reviews.llvm.org/D73210
1 parent 1484d0f commit f514776

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

llvm/lib/CodeGen/LiveDebugValues.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,12 @@ void LiveDebugValues::insertTransferDebugPair(
922922
void LiveDebugValues::transferRegisterDef(
923923
MachineInstr &MI, OpenRangesSet &OpenRanges, VarLocMap &VarLocIDs,
924924
TransferMap &Transfers) {
925+
926+
// Meta Instructions do not affect the debug liveness of any register they
927+
// define.
928+
if (MI.isMetaInstruction())
929+
return;
930+
925931
MachineFunction *MF = MI.getMF();
926932
const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
927933
unsigned SP = TLI->getStackPointerRegisterToSaveRestore();

llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# CHECK: ![[ARG_A:.*]] = !DILocalVariable(name: "a"
2020
# CHECK: ![[ARG_B:.*]] = !DILocalVariable(name: "b"
2121
# CHECK: ![[ARG_C:.*]] = !DILocalVariable(name: "c"
22-
# CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1)
2322
# CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
2423
# CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1)
2524
# CHECK-NOT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--- |
2+
; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE
3+
4+
; Check that live-debug-values ignores meta instructions.
5+
6+
; CHECK-LABEL: bb.0.entry:
7+
; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
8+
; CHECK-LABEL: bb.1.bb1:
9+
; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
10+
; CHECK-LABEL: bb.2.bb2:
11+
; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
12+
; CHECK-LABEL: bb.3.bb3:
13+
; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
14+
15+
define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
16+
entry:
17+
br label %bb1, !dbg !17
18+
bb1:
19+
br label %bb2, !dbg !17
20+
bb2:
21+
br label %bb3, !dbg !17
22+
bb3:
23+
ret i32 0, !dbg !17
24+
}
25+
26+
!llvm.dbg.cu = !{!0}
27+
!llvm.module.flags = !{!7, !8, !9, !10}
28+
!llvm.ident = !{!11}
29+
!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)
30+
!1 = !DIFile(filename: "main.cpp", directory: "F:\")
31+
!2 = !{}
32+
!3 = !{!4}
33+
!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
34+
!5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
35+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
36+
!7 = !{i32 2, !"Dwarf Version", i32 4}
37+
!8 = !{i32 2, !"Debug Info Version", i32 3}
38+
!9 = !{i32 1, !"wchar_size", i32 2}
39+
!10 = !{i32 7, !"PIC Level", i32 2}
40+
!11 = !{!"clang version 10.0.0"}
41+
!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)
42+
!13 = !DISubroutineType(types: !14)
43+
!14 = !{!6, !6}
44+
!15 = !{!16}
45+
!16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
46+
!17 = !DILocation(line: 10, scope: !12)
47+
48+
...
49+
---
50+
name: _Z8bb_to_bb
51+
body: |
52+
bb.0.entry:
53+
successors: %bb.1
54+
$ebx = MOV32ri 0, debug-location !17
55+
DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
56+
bb.1.bb1:
57+
successors: %bb.2
58+
renamable $ebx = KILL $ebx
59+
bb.2.bb2:
60+
successors: %bb.3
61+
renamable $ebx = KILL $ebx
62+
bb.3.bb3:
63+
RETQ $eax, debug-location !17
64+
...

0 commit comments

Comments
 (0)