1 # RUN: llc -run-pass=livedebugvalues -o - %s | FileCheck %s
3 # Based on the following C reproducer:
5 # extern void ext(int *);
6 # extern int interesting(int *);
7 # extern int *value(void);
9 # static void callee(int *p1, int *p2) {
10 # if (interesting(p2))
17 # int *local = value();
18 # callee(local, (int *)0xabcd);
23 # clang -Os -fno-inline -Xclang -femit-debug-entry-values -g --target=armeb.
26 target datalayout = "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
27 target triple = "armebv4t-unknown-unknown"
29 ; Function Attrs: noinline nounwind optsize
30 define arm_aapcs_vfpcc void @caller() #0 !dbg !20 {
35 ; Function Attrs: noinline nounwind optsize
36 define internal arm_aapcs_vfpcc void @callee(i32* %p1) unnamed_addr #0 !dbg !29 {
41 declare !dbg !4 arm_aapcs_vfpcc i32* @value()
42 declare !dbg !9 arm_aapcs_vfpcc i32 @interesting(i32*)
43 declare !dbg !12 arm_aapcs_vfpcc void @ext(i32*)
45 ; Function Attrs: nounwind readnone speculatable willreturn
46 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
48 attributes #0 = { noinline nounwind optsize "frame-pointer"="all" }
49 attributes #1 = { nounwind readnone speculatable willreturn }
52 !llvm.module.flags = !{!15, !16, !17, !18}
55 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
56 !1 = !DIFile(filename: "armeb.c", directory: "/")
58 !3 = !{!4, !7, !9, !12}
59 !4 = !DISubprogram(name: "value", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
60 !5 = !DISubroutineType(types: !6)
62 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32)
63 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
64 !9 = !DISubprogram(name: "interesting", scope: !1, file: !1, line: 2, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
65 !10 = !DISubroutineType(types: !11)
67 !12 = !DISubprogram(name: "ext", scope: !1, file: !1, line: 1, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
68 !13 = !DISubroutineType(types: !14)
70 !15 = !{i32 2, !"Dwarf Version", i32 4}
71 !16 = !{i32 2, !"Debug Info Version", i32 3}
72 !17 = !{i32 1, !"wchar_size", i32 4}
73 !18 = !{i32 1, !"min_enum_size", i32 4}
74 !19 = !{!"clang version 10.0.0"}
75 !20 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 12, type: !21, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !23)
76 !21 = !DISubroutineType(types: !22)
79 !24 = !DILocalVariable(name: "local", scope: !20, file: !1, line: 13, type: !7)
80 !25 = !DILocation(line: 13, scope: !20)
81 !26 = !DILocation(line: 0, scope: !20)
82 !27 = !DILocation(line: 14, scope: !20)
83 !28 = !DILocation(line: 15, scope: !20)
84 !29 = distinct !DISubprogram(name: "callee", scope: !1, file: !1, line: 5, type: !30, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !32)
85 !30 = !DISubroutineType(types: !31)
88 !33 = !DILocalVariable(name: "p1", arg: 1, scope: !29, file: !1, line: 5, type: !7)
89 !34 = !DILocalVariable(name: "p2", arg: 2, scope: !29, file: !1, line: 5, type: !7)
90 !35 = !DILocation(line: 0, scope: !29)
91 !36 = !DILocation(line: 6, scope: !37)
92 !37 = distinct !DILexicalBlock(scope: !29, file: !1, line: 6)
93 !38 = !DILocation(line: 6, scope: !29)
94 !39 = !DILocation(line: 7, scope: !40)
95 !40 = distinct !DILexicalBlock(scope: !37, file: !1, line: 7)
96 !41 = !DILocation(line: 8, scope: !42)
97 !42 = distinct !DILexicalBlock(scope: !40, file: !1, line: 7)
98 !43 = !DILocation(line: 7, scope: !42)
99 !44 = distinct !{!44, !39, !45}
100 !45 = !DILocation(line: 8, scope: !40)
101 !46 = !DILocation(line: 9, scope: !29)
102 !47 = !DILocation(line: 10, scope: !29)
108 tracksRegLiveness: true
113 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, $r11, killed $lr
114 frame-setup CFI_INSTRUCTION def_cfa_offset 8
115 frame-setup CFI_INSTRUCTION offset $lr, -4
116 frame-setup CFI_INSTRUCTION offset $r11, -8
117 $r11 = frame-setup MOVr $sp, 14, $noreg, $noreg
118 frame-setup CFI_INSTRUCTION def_cfa_register $r11
119 BL @value, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $r0, debug-location !25
120 DBG_VALUE $r0, $noreg, !24, !DIExpression(), debug-location !26
121 $sp = LDMIA_UPD $sp, 14, $noreg, def $r11, def $lr, debug-location !27
122 TAILJMPd @callee, implicit $sp, implicit $sp, implicit killed $r0, debug-location !27
127 tracksRegLiveness: true
129 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
130 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
131 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
132 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
133 stack-id: default, callee-saved-register: '$r11', callee-saved-restored: true,
134 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
135 - { id: 2, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
136 stack-id: default, callee-saved-register: '$r10', callee-saved-restored: true,
137 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
138 - { id: 3, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,
139 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
140 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
143 successors: %bb.2(0x30000000), %bb.1(0x50000000)
144 liveins: $r0, $r4, $r10, $lr
146 DBG_VALUE $r0, $noreg, !33, !DIExpression(), debug-location !35
147 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r4, killed $r10, $r11, killed $lr
148 frame-setup CFI_INSTRUCTION def_cfa_offset 16
149 frame-setup CFI_INSTRUCTION offset $lr, -4
150 frame-setup CFI_INSTRUCTION offset $r11, -8
151 frame-setup CFI_INSTRUCTION offset $r10, -12
152 frame-setup CFI_INSTRUCTION offset $r4, -16
153 $r11 = frame-setup ADDri $sp, 8, 14, $noreg, $noreg
154 frame-setup CFI_INSTRUCTION def_cfa $r11, 8
155 $r4 = MOVr killed $r0, 14, $noreg, $noreg
156 DBG_VALUE $r4, $noreg, !33, !DIExpression(), debug-location !35
157 $r0 = MOVi 205, 14, $noreg, $noreg
158 $r0 = ORRri killed $r0, 43776, 14, $noreg, $noreg
159 ; The MOVI and ORRri produce the second parameter's (!34) value which has
160 ; been propagated from caller().
161 DBG_VALUE $r0, $noreg, !34, !DIExpression(), debug-location !35
162 BL @interesting, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def $r0, debug-location !36
163 CMPri killed renamable $r0, 0, 14, $noreg, implicit-def $cpsr, debug-location !38
164 Bcc %bb.2, 0, killed $cpsr, debug-location !38
169 $r0 = MOVr $r4, 14, $noreg, $noreg, debug-location !41
170 BL @ext, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, debug-location !41
171 B %bb.1, debug-location !43
174 $r0 = MOVi 205, 14, $noreg, $noreg
175 $r0 = ORRri killed $r0, 43776, 14, $noreg, $noreg
176 $sp = LDMIA_UPD $sp, 14, $noreg, def $r4, def $r10, def $r11, def $lr, debug-location !46
177 TAILJMPd @ext, implicit $sp, implicit $sp, implicit killed $r0, debug-location !46
181 # In this test case the second parameter's value has been propagated from the
182 # caller to the callee, so we should not emit any entry value DBG_VALUEs for
183 # that parameter. The second parameter reuses the first parameter's register
184 # ($r0), and previously we would incorrectly emit an entry value for the
185 # parameter using that register.
187 # CHECK-DAG: ![[P1:[0-9]+]] = !DILocalVariable(name: "p1", arg: 1
188 # CHECK-DAG: ![[P2:[0-9]+]] = !DILocalVariable(name: "p2", arg: 2
190 # CHECK-NOT: DBG_VALUE $r0, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_entry_value
192 # CHECK: DBG_VALUE $r0, $noreg, ![[P1]], !DIExpression(DW_OP_LLVM_entry_value
194 # CHECK-NOT: DBG_VALUE $r0, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_entry_value