1 # RUN: llc %s -o - -run-pass=removeredundantdebugvalues | FileCheck --implicit-check-not=DBG_VALUE %s
3 ## This checks that the RemoveRedundantDebugValues removes redundant
4 ## DBG_VALUEs. The MIR was hand-written, and foo{[2-6]}() are just
5 ## copies of foo(), with an extra instruction that modifies the $edi register
6 ## and extra (artificial) DBG_VALUE and DBG_VALUE_LIST instructions.
9 # CHECK-LABEL: bb.0.entry:
10 # CHECK: DBG_VALUE $edi
11 # CHECK-NOT: DBG_VALUE $edi
12 # CHECK: frame-setup PUSH64r
13 # CHECK: MOV32mr $rip, 1, $noreg
14 # CHECK-NOT: DBG_VALUE $edi
17 # CHECK-LABEL: bb.0.entry:
20 # CHECK: frame-setup PUSH64r
23 # CHECK-LABEL: bb.0.entry:
24 # CHECK: DBG_VALUE $edi
25 # CHECK: MOV32mr $rip, 1, $noreg
26 # CHECK: DBG_VALUE $edi
29 # CHECK-LABEL: bb.0.entry:
30 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
31 # CHECK: DBG_VALUE $esi, {{.*}}, !DIExpression()
32 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
35 # CHECK-LABEL: bb.0.entry:
36 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
37 # CHECK: DBG_VALUE_LIST !{{.*}}
38 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
41 # CHECK-LABEL: bb.0.entry:
42 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
43 # CHECK: DBG_VALUE 0, {{.*}}, !DIExpression()
44 # CHECK: DBG_VALUE $edi, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
47 ; ModuleID = 'test.ll'
48 source_filename = "test.c"
49 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
50 target triple = "x86_64-unknown-linux-gnu"
52 @side_effect = external dso_local local_unnamed_addr global i32, align 4
53 @value = external dso_local local_unnamed_addr global i32, align 4
55 ; Function Attrs: nounwind uwtable
56 define dso_local i32 @foo(i32 %param) local_unnamed_addr !dbg !8 {
58 call void @llvm.dbg.value(metadata i32 %param, metadata !13, metadata !DIExpression()), !dbg !14
59 store i32 %param, i32* @side_effect, align 4, !dbg !15
60 %0 = load i32, i32* @value, align 4, !dbg !20
61 call void @llvm.dbg.value(metadata i32 %0, metadata !13, metadata !DIExpression()), !dbg !14
62 tail call void @bar(i32 %0), !dbg !21
66 define dso_local i32 @foo6(i32 %param) local_unnamed_addr !dbg !34 {
68 store i32 %param, i32* @side_effect, align 4, !dbg !35
69 %0 = load i32, i32* @value, align 4, !dbg !35
70 tail call void @bar(i32 %0), !dbg !35
74 ; Function Attrs: nounwind uwtable
75 define dso_local i32 @foo2(i32 %param) local_unnamed_addr !dbg !26 {
77 store i32 %param, i32* @side_effect, align 4, !dbg !27
78 %0 = load i32, i32* @value, align 4, !dbg !27
79 tail call void @bar(i32 %0), !dbg !27
83 ; Function Attrs: nounwind uwtable
84 define dso_local i32 @foo3(i32 %param) local_unnamed_addr !dbg !28 {
86 store i32 %param, i32* @side_effect, align 4, !dbg !29
87 %0 = load i32, i32* @value, align 4, !dbg !29
88 tail call void @bar(i32 %0), !dbg !29
92 ; Function Attrs: nounwind uwtable
93 define dso_local i32 @foo4(i32 %param) local_unnamed_addr !dbg !30 {
95 store i32 %param, i32* @side_effect, align 4, !dbg !31
96 %0 = load i32, i32* @value, align 4, !dbg !31
97 tail call void @bar(i32 %0), !dbg !31
101 ; Function Attrs: nounwind uwtable
102 define dso_local i32 @foo5(i32 %param) local_unnamed_addr !dbg !32 {
104 store i32 %param, i32* @side_effect, align 4, !dbg !33
105 %0 = load i32, i32* @value, align 4, !dbg !33
106 tail call void @bar(i32 %0), !dbg !33
110 declare !dbg !23 dso_local void @bar(i32) local_unnamed_addr
112 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
113 declare void @llvm.dbg.value(metadata, metadata, metadata)
116 !llvm.module.flags = !{!3, !4, !5, !6}
119 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
120 !1 = !DIFile(filename: "test.c", directory: "/dir")
122 !3 = !{i32 7, !"Dwarf Version", i32 4}
123 !4 = !{i32 2, !"Debug Info Version", i32 3}
124 !5 = !{i32 1, !"wchar_size", i32 4}
125 !6 = !{i32 7, !"uwtable", i32 1}
126 !7 = !{!"clang version 13.0.0"}
127 !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
128 !9 = !DISubroutineType(types: !10)
130 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
132 !13 = !DILocalVariable(name: "param", arg: 1, scope: !8, file: !1, line: 4, type: !11)
133 !14 = !DILocation(line: 0, scope: !8)
134 !15 = !DILocation(line: 5, column: 17, scope: !8)
135 !20 = !DILocation(line: 6, column: 13, scope: !8)
136 !21 = !DILocation(line: 7, column: 5, scope: !8)
137 !22 = !DILocation(line: 8, column: 5, scope: !8)
138 !23 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !24, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
139 !24 = !DISubroutineType(types: !25)
141 !26 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
142 !27 = !DILocation(line: 0, scope: !26)
143 !28 = distinct !DISubprogram(name: "foo3", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
144 !29 = !DILocation(line: 0, scope: !28)
145 !30 = distinct !DISubprogram(name: "foo4", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
146 !31 = !DILocation(line: 0, scope: !30)
147 !32 = distinct !DISubprogram(name: "foo5", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
148 !33 = !DILocation(line: 0, scope: !32)
149 !34 = distinct !DISubprogram(name: "foo6", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
150 !35 = !DILocation(line: 0, scope: !34)
157 - { reg: '$edi', virtual-reg: '' }
162 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
163 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
164 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
165 CFI_INSTRUCTION def_cfa_offset 16
166 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
167 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
168 CALL64pcrel32 @bar, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !21
169 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
170 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
171 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
172 RETQ killed $eax, debug-location !22
179 - { reg: '$edi', virtual-reg: '' }
184 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
185 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
186 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
187 CFI_INSTRUCTION def_cfa_offset 16
188 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
189 renamable $edi = MOV32rm $rip, 1, $noreg, @value, $noreg, debug-location !20 :: (dereferenceable load 4 from @value)
190 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !14
191 CALL64pcrel32 @bar, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !21
192 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
193 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
194 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
195 RETQ killed $eax, debug-location !22
202 - { reg: '$edi', virtual-reg: '' }
207 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
208 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
209 CFI_INSTRUCTION def_cfa_offset 16
210 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
211 renamable $esi = MOV32rm $rip, 1, $noreg, @value, $noreg, debug-location !20 :: (dereferenceable load 4 from @value)
212 DBG_VALUE $esi, $noreg, !13, !DIExpression(), debug-location !14
213 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
214 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
215 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
216 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
217 RETQ killed $eax, debug-location !22
224 - { reg: '$edi', virtual-reg: '' }
229 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
230 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
231 CFI_INSTRUCTION def_cfa_offset 16
232 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
233 renamable $esi = MOV32rm $rip, 1, $noreg, @value, $noreg, debug-location !20 :: (dereferenceable load 4 from @value)
234 DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $edi, $esi, debug-location !14
235 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
236 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
237 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
238 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
239 RETQ killed $eax, debug-location !22
246 - { reg: '$edi', virtual-reg: '' }
251 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
252 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
253 CFI_INSTRUCTION def_cfa_offset 16
254 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
255 renamable $esi = MOV32rm $rip, 1, $noreg, @value, $noreg, debug-location !20 :: (dereferenceable load 4 from @value)
256 DBG_VALUE 0, $noreg, !13, !DIExpression(), debug-location !14
257 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
258 DBG_VALUE $edi, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !14
259 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
260 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
261 RETQ killed $eax, debug-location !22
268 - { reg: '$edi', virtual-reg: '' }
273 DBG_VALUE 0, $noreg, !13, !DIExpression(), debug-location !14
274 DBG_VALUE 1, $noreg, !13, !DIExpression(), debug-location !14
275 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
276 CFI_INSTRUCTION def_cfa_offset 16
277 MOV32mr $rip, 1, $noreg, @side_effect, $noreg, killed renamable $esi, debug-location !15 :: (store 4 into @side_effect)
278 renamable $esi = MOV32rm $rip, 1, $noreg, @value, $noreg, debug-location !20 :: (dereferenceable load 4 from @value)
279 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !22
280 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !22
281 CFI_INSTRUCTION def_cfa_offset 8, debug-location !22
282 RETQ killed $eax, debug-location !22