Skip to content

Commit 60db26a

Browse files
committed
[LiveDebugValues][NFC] Add instr-ref tests, adapt old tests
This patch adds a few tests in DebugInfo/MIR/InstrRef/ of interesting behaviour that the instruction referencing implementation of LiveDebugValues has. Mostly, these tests exist to ensure that if you give the "-experimental-debug-variable-locations" command line switch, the right implementation runs; and to ensure it behaves the same way as the VarLoc LiveDebugValues implementation. I've also touched roughly 30 other tests, purely to make the tests less rigid about what output to accept. DBG_VALUE instructions are usually printed with a trailing !debug-location indicating its scope: !debug-location !1234 However InstrRefBasedLDV produces new DebugLoc instances on the fly, meaning there sometimes isn't a numbered node when they're printed, making the output: !debug-location !DILocation(line: 0, blah blah) Which causes a ton of these tests to fail. This patch removes checks for that final part of each DBG_VALUE instruction. None of them appear to be actually checking the scope is correct, just that it's present, so I don't believe there's any loss in coverage here. Differential Revision: https://reviews.llvm.org/D83054
1 parent f1a9873 commit 60db26a

27 files changed

+901
-99
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
--- |
2+
; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations -emulate-old-livedebugvalues=0 | FileCheck %s -implicit-check-not=DBG_VALUE
3+
4+
; This test has two loop heads (bb1, bb2) and a PHI going into bb5. In bb2,
5+
; we need to explore / downgrade from the value of ebx def'd in the entry
6+
; block, through the first loop head, then propose and confirm a PHI at the
7+
; second loop head.
8+
9+
;; Checks represent each DBG_VALUE in the MIR below, and the a live-in
10+
;; DBG_VALUE at the start of each block added by LiveDebugValues.
11+
12+
; CHECK-LABEL: bb.0.entry:
13+
; CHECK: DBG_VALUE $eax
14+
; CHECK-LABEL: bb.1.bb1:
15+
; CHECK: DBG_VALUE $ebx
16+
; CHECK: DBG_VALUE $ebx
17+
; CHECK-LABEL: bb.2.bb2:
18+
; CHECK: DBG_VALUE $ebx
19+
; CHECK-LABEL: bb.3.bb3:
20+
; CHECK: DBG_VALUE $ebx
21+
; CHECK: DBG_VALUE $ebx
22+
; CHECK-LABEL: bb.4.bb4:
23+
; CHECK: DBG_VALUE $ebx
24+
; CHECK-LABEL: bb.5.bb5:
25+
; CHECK: DBG_VALUE $ebx
26+
; CHECK-LABEL: bb.6:
27+
; CHECK: DBG_VALUE $ebx
28+
; CHECK-LABEL: bb.7:
29+
; CHECK: DBG_VALUE $ebx
30+
31+
define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
32+
entry:
33+
br label %bb1, !dbg !17
34+
bb1:
35+
br label %bb2, !dbg !17
36+
bb2:
37+
br label %bb3, !dbg !17
38+
bb3:
39+
br label %bb3, !dbg !17
40+
bb4:
41+
br label %bb3, !dbg !17
42+
bb5:
43+
ret i32 0, !dbg !17
44+
}
45+
46+
!llvm.dbg.cu = !{!0}
47+
!llvm.module.flags = !{!7, !8, !9, !10}
48+
!llvm.ident = !{!11}
49+
!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)
50+
!1 = !DIFile(filename: "main.cpp", directory: "F:\")
51+
!2 = !{}
52+
!3 = !{!4}
53+
!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
54+
!5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
55+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56+
!7 = !{i32 2, !"Dwarf Version", i32 4}
57+
!8 = !{i32 2, !"Debug Info Version", i32 3}
58+
!9 = !{i32 1, !"wchar_size", i32 2}
59+
!10 = !{i32 7, !"PIC Level", i32 2}
60+
!11 = !{!"clang version 10.0.0"}
61+
!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)
62+
!13 = !DISubroutineType(types: !14)
63+
!14 = !{!6, !6}
64+
!15 = !{!16}
65+
!16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
66+
!17 = !DILocation(line: 10, scope: !12)
67+
68+
...
69+
---
70+
name: _Z8bb_to_bb
71+
body: |
72+
bb.0.entry:
73+
successors: %bb.1
74+
$ebx = MOV32ri 0, debug-location !17
75+
$eax = COPY $ebx
76+
DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17
77+
bb.1.bb1:
78+
successors: %bb.2
79+
$eax = COPY $ebx, debug-location !17
80+
$ebx = COPY $ecx, debug-location !17
81+
DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
82+
bb.2.bb2:
83+
successors: %bb.3, %bb.4
84+
JCC_1 %bb.4, 4, implicit $eflags
85+
bb.3.bb3:
86+
successors: %bb.5
87+
$ebx = MOV32ri 0, debug-location !17
88+
DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
89+
JMP_1 %bb.5
90+
bb.4.bb4:
91+
successors: %bb.5
92+
bb.5.bb5:
93+
successors: %bb.2, %bb.6
94+
JCC_1 %bb.2, 4, implicit killed $eflags
95+
bb.6:
96+
successors: %bb.1, %bb.7
97+
JCC_1 %bb.1, 4, implicit killed $eflags
98+
bb.7:
99+
RETQ $eax, debug-location !17
100+
...
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
--- |
2+
; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s --implicit-check-not=DBG_VALUE
3+
; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations | FileCheck %s --implicit-check-not=DBG_VALUE
4+
;
5+
; No DBG_VALUEs should be propagated, as there's a loop between bb2 and bb3
6+
; that defines $rdi without specifying it as being the variable value. Uses
7+
; implicit check-not in runlines above.
8+
;
9+
; CHECK-LABEL: bb.1.while.body
10+
; CHECK: DBG_VALUE
11+
; CHECK-NEXT: TEST8rr
12+
; CHECK-NEXT: JCC_1
13+
14+
; ModuleID = 'multi-downgrade-but-not-sensitive.ll'
15+
source_filename = "/fast/fs/llvm3/clang/lib/CodeGen/CoverageMappingGen.cpp"
16+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
17+
target triple = "x86_64-unknown-linux-gnu"
18+
19+
%"struct.std::pair.1976" = type { %"class.clang::SourceLocation", i32 }
20+
%"class.clang::SourceLocation" = type { i32 }
21+
22+
; Function Attrs: nounwind uwtable
23+
define weak_odr void @_ZSt17__merge_sort_loopIPSt4pairIN5clang14SourceLocationEjES4_lN9__gnu_cxx5__ops15_Iter_comp_iterIN4llvm11less_secondEEEEvT_SB_T0_T1_T2_(%"struct.std::pair.1976"* %__result) local_unnamed_addr !dbg !12 {
24+
while.body.lr.ph:
25+
br label %while.body, !dbg !17
26+
27+
while.body: ; preds = %while.body, %while.body.i, %while.body.lr.ph
28+
%__result.addr.099 = phi %"struct.std::pair.1976"* [ %__result, %while.body.lr.ph ], [ %__result.addr.099, %while.body ], [ %incdec.ptr7.i, %while.body.i ]
29+
call void @llvm.dbg.value(metadata %"struct.std::pair.1976"* %__result.addr.099, metadata !16, metadata !DIExpression()), !dbg !17
30+
br i1 undef, label %while.body.i.preheader, label %while.body, !dbg !17
31+
32+
while.body.i.preheader: ; preds = %while.body
33+
br label %while.body.i, !dbg !17
34+
35+
while.body.i: ; preds = %while.body.i, %while.body.i.preheader
36+
%__result.addr.046.i = phi %"struct.std::pair.1976"* [ %incdec.ptr7.i, %while.body.i ], [ %__result.addr.099, %while.body.i.preheader ]
37+
%incdec.ptr7.i = getelementptr inbounds %"struct.std::pair.1976", %"struct.std::pair.1976"* %__result.addr.046.i, i64 1, !dbg !17
38+
%cmp.not.i = icmp ne %"struct.std::pair.1976"* undef, undef, !dbg !17
39+
%0 = and i1 undef, %cmp.not.i, !dbg !17
40+
br i1 %0, label %while.body.i, label %while.body, !dbg !17
41+
}
42+
43+
; Function Attrs: nounwind readnone speculatable willreturn
44+
declare void @llvm.dbg.value(metadata, metadata, metadata)
45+
46+
; Function Attrs: nounwind
47+
declare void @llvm.stackprotector(i8*, i8**)
48+
49+
!llvm.dbg.cu = !{!0}
50+
!llvm.module.flags = !{!7, !8, !9, !10}
51+
!llvm.ident = !{!11}
52+
!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)
53+
!1 = !DIFile(filename: "main.cpp", directory: "F:\")
54+
!2 = !{}
55+
!3 = !{!4}
56+
!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
57+
!5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
58+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
59+
!7 = !{i32 2, !"Dwarf Version", i32 4}
60+
!8 = !{i32 2, !"Debug Info Version", i32 3}
61+
!9 = !{i32 1, !"wchar_size", i32 2}
62+
!10 = !{i32 7, !"PIC Level", i32 2}
63+
!11 = !{!"clang version 10.0.0"}
64+
!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)
65+
!13 = !DISubroutineType(types: !14)
66+
!14 = !{!6, !6}
67+
!15 = !{!16}
68+
!16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
69+
!17 = !DILocation(line: 10, scope: !12)
70+
71+
72+
...
73+
---
74+
name: _ZSt17__merge_sort_loopIPSt4pairIN5clang14SourceLocationEjES4_lN9__gnu_cxx5__ops15_Iter_comp_iterIN4llvm11less_secondEEEEvT_SB_T0_T1_T2_
75+
alignment: 16
76+
tracksRegLiveness: true
77+
registers: []
78+
liveins:
79+
- { reg: '$rdi', virtual-reg: '' }
80+
machineFunctionInfo: {}
81+
body: |
82+
bb.0.while.body.lr.ph:
83+
successors: %bb.1(0x80000000)
84+
liveins: $rdi
85+
86+
renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
87+
88+
bb.1.while.body (align 16):
89+
successors: %bb.2(0x40000000), %bb.1(0x40000000)
90+
liveins: $eax, $rdi
91+
92+
DBG_VALUE $rdi, $noreg, !16, !DIExpression(), debug-location !17
93+
TEST8rr renamable $al, renamable $al, implicit-def $eflags, debug-location !17
94+
JCC_1 %bb.1, 5, implicit killed $eflags, debug-location !17
95+
96+
bb.2.while.body.i (align 16):
97+
successors: %bb.3(0x7e000000), %bb.1(0x02000000)
98+
liveins: $eax, $rdi
99+
100+
renamable $rdi = nuw ADD64ri8 killed renamable $rdi, 8, implicit-def dead $eflags, debug-location !17
101+
TEST8rr renamable $al, renamable $al, implicit-def $eflags, debug-location !17
102+
JCC_1 %bb.1, 5, implicit $eflags, debug-location !17
103+
104+
bb.3.while.body.i:
105+
successors: %bb.2(0x7df7df7e), %bb.1(0x02082082)
106+
liveins: $eax, $rdi
107+
108+
TEST8rr renamable $al, renamable $al, implicit-def $eflags, debug-location !17
109+
JCC_1 %bb.2, 5, implicit $eflags
110+
JMP_1 %bb.1
111+
112+
...

0 commit comments

Comments
 (0)