1 # RUN: llc -start-after=livedebugvalues -filetype=obj -o - %s \
2 # RUN: | llvm-dwarfdump -v - | FileCheck %s
4 # This tests for a crash in DwarfDebug's singular DBG_VALUE range promotion when
5 # encountering an IMPLICIT_DEF in its own lexical scope.
7 # CHECK: .debug_info contents:
8 # CHECK: DW_TAG_formal_parameter
9 # CHECK: DW_AT_location [DW_FORM_sec_offset]
10 # CHECK-NEXT: DW_OP_lit0, DW_OP_stack_value
11 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "name"
14 source_filename = "t.ll"
15 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
16 target triple = "aarch64--linux-gnu"
18 %class.v = type <{ i32, i8, i8, [2 x i8] }>
19 %class.j = type <{ %"class.j<6, a::f>::D", i32, [4 x i8] }>
20 %"class.j<6, a::f>::D" = type { %"class.j<6, a::f>::p" }
21 %"class.j<6, a::f>::p" = type { i64 }
23 @bt = global i32 0, align 4
25 define void @_ZN1v2bvEv(%class.v* nocapture readonly %this) local_unnamed_addr align 2 !dbg !14 {
27 %bz = alloca %class.j, align 8
28 %att = alloca %class.j, align 8
29 %ap = getelementptr inbounds %class.v, %class.v* %this, i64 0, i32 1
30 %0 = load i8, i8* %ap, align 4
31 %conv = sext i8 %0 to i32
32 switch i32 %conv, label %sw.epilog [
33 i32 1, label %_ZN1jILi6EN1a1fEE1mEj.exit
37 _ZN1jILi6EN1a1fEE1mEj.exit: ; preds = %entry
38 %1 = bitcast %class.j* %att to i64*
39 %2 = bitcast %class.j* %bz to i64*
40 store i64 1, i64* %2, align 8
41 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !18, metadata !23), !dbg !24
42 store i64 1, i64* %1, align 8, !dbg !27
45 sw.bb2: ; preds = %entry
46 %3 = bitcast %class.j* %att to i64*
47 %4 = bitcast %class.j* %bz to i64*
48 %.pre = load i64, i64* %3, align 8
49 %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i13.phi.trans.insert = getelementptr inbounds %class.j, %class.j* %bz, i64 0, i32 1
50 %.phi.trans.insert = bitcast i32* %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i13.phi.trans.insert to i64*
51 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14.pre = load i64, i64* %.phi.trans.insert, align 8
52 %.pre25 = load i64, i64* %4, align 8
53 %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i.phi.trans.insert = getelementptr inbounds %class.j, %class.j* %att, i64 0, i32 1
54 %.phi.trans.insert26 = bitcast i32* %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i.phi.trans.insert to i64*
55 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i.pre = load i64, i64* %.phi.trans.insert26, align 8
58 sw.epilog: ; preds = %sw.bb2, %_ZN1jILi6EN1a1fEE1mEj.exit, %entry
59 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i = phi i64 [ %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i.pre, %sw.bb2 ], [ undef, %entry ], [ undef, %_ZN1jILi6EN1a1fEE1mEj.exit ], !dbg !32
60 %5 = phi i64 [ %.pre25, %sw.bb2 ], [ 0, %entry ], [ 1, %_ZN1jILi6EN1a1fEE1mEj.exit ]
61 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14 = phi i64 [ %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14.pre, %sw.bb2 ], [ undef, %entry ], [ undef, %_ZN1jILi6EN1a1fEE1mEj.exit ]
62 %6 = phi i64 [ %.pre, %sw.bb2 ], [ 0, %entry ], [ 1, %_ZN1jILi6EN1a1fEE1mEj.exit ]
63 %bw1 = bitcast %class.v* %this to i32*
64 %7 = load i32, i32* %bw1, align 4
65 %bx = getelementptr inbounds %class.v, %class.v* %this, i64 0, i32 2
66 %8 = load i8, i8* %bx, align 1
67 %tobool = icmp ne i8 %8, 0
68 %.fca.0.insert9 = insertvalue [2 x i64] undef, i64 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14, 0
69 %.fca.1.insert12 = insertvalue [2 x i64] %.fca.0.insert9, i64 %5, 1
70 %.fca.0.insert = insertvalue [2 x i64] undef, i64 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i, 0
71 %.fca.1.insert = insertvalue [2 x i64] %.fca.0.insert, i64 %6, 1
72 call void @_Z2byi1LS_bbPi(i32 %7, [2 x i64] %.fca.1.insert12, [2 x i64] %.fca.1.insert, i1 %tobool, i1 false, i32* nonnull @bt)
76 declare void @_Z2byi1LS_bbPi(i32, [2 x i64], [2 x i64], i1, i1, i32*) local_unnamed_addr
78 ; Function Attrs: nounwind readnone speculatable
79 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #0
81 ; Function Attrs: nounwind
82 declare void @llvm.stackprotector(i8*, i8**) #1
84 attributes #0 = { nounwind readnone speculatable }
85 attributes #1 = { nounwind }
88 !llvm.module.flags = !{!12, !13}
90 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 305696) (llvm/trunk 305708)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !2)
91 !1 = !DIFile(filename: "/<stdin>", directory: "/")
94 !4 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "r", file: !5, line: 50, size: 8, elements: !6, identifier: "_ZTS1r")
95 !5 = !DIFile(filename: "current.ii", directory: "/")
97 !7 = !DISubprogram(name: "r", scope: !4, file: !5, line: 52, type: !8, isLocal: false, isDefinition: false, scopeLine: 52, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true)
98 !8 = !DISubroutineType(types: !9)
100 !10 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "q", scope: !11, file: !5, line: 39, size: 64, elements: !2, identifier: "_ZTSN1jILi6EN1a1fEE1qE")
101 !11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "j<6, a::f>", file: !5, line: 7, size: 128, elements: !2, templateParams: !2, identifier: "_ZTS1jILi6EN1a1fEE")
102 !12 = !{i32 2, !"Debug Info Version", i32 3}
103 !13 = !{i32 1, !"wchar_size", i32 4}
104 !14 = distinct !DISubprogram(name: "bv", linkageName: "_ZN1v2bvEv", scope: !15, file: !5, line: 104, type: !16, isLocal: false, isDefinition: true, scopeLine: 104, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !17, retainedNodes: !2)
105 !15 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "v", file: !5, line: 97, size: 64, elements: !2, identifier: "_ZTS1v")
106 !16 = !DISubroutineType(types: !2)
107 !17 = !DISubprogram(name: "bv", linkageName: "_ZN1v2bvEv", scope: !15, file: !5, line: 98, type: !16, isLocal: false, isDefinition: false, scopeLine: 98, flags: DIFlagPrototyped, isOptimized: true)
108 !18 = !DILocalVariable(name: "name", arg: 2, scope: !19, file: !5, line: 22, type: !21)
109 !19 = distinct !DISubprogram(name: "m", linkageName: "_ZN1jILi6EN1a1fEE1mEj", scope: !11, file: !5, line: 22, type: !16, isLocal: false, isDefinition: true, scopeLine: 22, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !20, retainedNodes: !2)
110 !20 = !DISubprogram(name: "m", linkageName: "_ZN1jILi6EN1a1fEE1mEj", scope: !11, file: !5, line: 22, type: !16, isLocal: false, isDefinition: false, scopeLine: 22, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true)
111 !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "h", file: !5, line: 10, baseType: !22)
112 !22 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
113 !23 = !DIExpression()
114 !24 = !DILocation(line: 22, scope: !19, inlinedAt: !25)
115 !25 = distinct !DILocation(line: 109, scope: !26)
116 !26 = distinct !DILexicalBlock(scope: !14, file: !5, line: 106)
117 !27 = !DILocation(line: 29, scope: !28, inlinedAt: !31)
118 !28 = distinct !DISubprogram(name: "n", linkageName: "_ZN1jILi6EN1a1fEE1p1nEl", scope: !29, file: !5, line: 29, type: !8, isLocal: false, isDefinition: true, scopeLine: 29, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !30, retainedNodes: !2)
119 !29 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "p", scope: !11, file: !5, line: 26, size: 64, elements: !2, identifier: "_ZTSN1jILi6EN1a1fEE1pE")
120 !30 = !DISubprogram(name: "n", linkageName: "_ZN1jILi6EN1a1fEE1p1nEl", scope: !29, file: !5, line: 29, type: !8, isLocal: false, isDefinition: false, scopeLine: 29, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true)
121 !31 = distinct !DILocation(line: 24, scope: !19, inlinedAt: !25)
122 !32 = !DILocation(line: 61, scope: !33, inlinedAt: !38)
123 !33 = distinct !DISubprogram(name: "bc<j<6, a::f> >", linkageName: "_ZN1s2bcI1jILi6EN1a1fEEEEDTcl2badeclsr1aE2aaIPT_EEEES6_", scope: !34, file: !5, line: 60, type: !16, isLocal: false, isDefinition: true, scopeLine: 60, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !36, declaration: !35, retainedNodes: !2)
124 !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !5, line: 59, size: 8, elements: !2, identifier: "_ZTS1s")
125 !35 = !DISubprogram(name: "bc<j<6, a::f> >", linkageName: "_ZN1s2bcI1jILi6EN1a1fEEEEDTcl2badeclsr1aE2aaIPT_EEEES6_", scope: !34, file: !5, line: 60, type: !16, isLocal: false, isDefinition: false, scopeLine: 60, flags: DIFlagPrototyped, isOptimized: true, templateParams: !36)
127 !37 = !DITemplateTypeParameter(name: "ay", type: !11)
128 !38 = distinct !DILocation(line: 70, scope: !39, inlinedAt: !42)
129 !39 = distinct !DISubprogram(name: "bc", linkageName: "_ZN1JI1s1jILi6EN1a1fEEE2bcEPS4_", scope: !40, file: !5, line: 70, type: !16, isLocal: false, isDefinition: true, scopeLine: 70, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !41, retainedNodes: !2)
130 !40 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "J<s, j<6, a::f> >", file: !5, line: 69, size: 8, elements: !2, templateParams: !2, identifier: "_ZTS1JI1s1jILi6EN1a1fEEE")
131 !41 = !DISubprogram(name: "bc", linkageName: "_ZN1JI1s1jILi6EN1a1fEEE2bcEPS4_", scope: !40, file: !5, line: 70, type: !16, isLocal: false, isDefinition: false, scopeLine: 70, flags: DIFlagPrototyped, isOptimized: true)
132 !42 = distinct !DILocation(line: 85, scope: !43, inlinedAt: !46)
133 !43 = distinct !DISubprogram(name: "u<j<6, a::f> >", linkageName: "_ZN1uC2I1jILi6EN1a1fEEEERT_", scope: !44, file: !5, line: 85, type: !16, isLocal: false, isDefinition: true, scopeLine: 85, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !36, declaration: !45, retainedNodes: !2)
134 !44 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "u", file: !5, line: 82, size: 128, elements: !2, identifier: "_ZTS1u")
135 !45 = !DISubprogram(name: "u<j<6, a::f> >", scope: !44, file: !5, line: 85, type: !16, isLocal: false, isDefinition: false, scopeLine: 85, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true, templateParams: !36)
136 !46 = distinct !DILocation(line: 85, scope: !47, inlinedAt: !48)
137 !47 = distinct !DISubprogram(name: "u<j<6, a::f> >", linkageName: "_ZN1uC1I1jILi6EN1a1fEEEERT_", scope: !44, file: !5, line: 85, type: !16, isLocal: false, isDefinition: true, scopeLine: 85, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !36, declaration: !45, retainedNodes: !2)
138 !48 = distinct !DILocation(line: 92, scope: !49, inlinedAt: !52)
139 !49 = distinct !DISubprogram(name: "L<j<6, a::f> >", linkageName: "_ZN1LC2I1jILi6EN1a1fEEEERT_", scope: !50, file: !5, line: 92, type: !16, isLocal: false, isDefinition: true, scopeLine: 92, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !2, declaration: !51, retainedNodes: !2)
140 !50 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "L", file: !5, line: 88, size: 128, elements: !2, identifier: "_ZTS1L")
141 !51 = !DISubprogram(name: "L<j<6, a::f> >", scope: !50, file: !5, line: 92, type: !16, isLocal: false, isDefinition: false, scopeLine: 92, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true, templateParams: !2)
142 !52 = distinct !DILocation(line: 92, scope: !53, inlinedAt: !54)
143 !53 = distinct !DISubprogram(name: "L<j<6, a::f> >", linkageName: "_ZN1LC1I1jILi6EN1a1fEEEERT_", scope: !50, file: !5, line: 92, type: !16, isLocal: false, isDefinition: true, scopeLine: 92, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !2, declaration: !51, retainedNodes: !2)
144 !54 = distinct !DILocation(line: 114, scope: !14)
150 exposesReturnsTwice: false
152 regBankSelected: false
154 tracksRegLiveness: true
157 - { reg: '$x0', virtual-reg: '' }
159 isFrameAddressTaken: false
160 isReturnAddressTaken: false
170 hasOpaqueSPAdjustment: false
172 hasMustTailInVarArgFunc: false
177 - { id: 0, name: bz, type: default, offset: -32, size: 16, alignment: 8,
178 callee-saved-register: '', local-offset: -16, debug-info-variable: '',
179 debug-info-expression: '', debug-info-location: '' }
180 - { id: 1, name: att, type: default, offset: -48, size: 16, alignment: 8,
181 callee-saved-register: '', local-offset: -32, debug-info-variable: '',
182 debug-info-expression: '', debug-info-location: '' }
183 - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
184 callee-saved-register: '$lr', debug-info-variable: '',
185 debug-info-expression: '', debug-info-location: '' }
189 successors: %bb.3.sw.bb2(0x2aaaaaab), %bb.1.entry(0x55555555)
192 $sp = frame-setup SUBXri $sp, 48, 0
193 frame-setup STRXui killed $lr, $sp, 4 :: (store 8 into %stack.2)
194 frame-setup CFI_INSTRUCTION def_cfa_offset 48
195 frame-setup CFI_INSTRUCTION offset $w30, -16
196 $w8 = LDRSBWui $x0, 4 :: (load 1 from %ir.ap, align 4)
197 CBZW $w8, %bb.3.sw.bb2
200 successors: %bb.2._ZN1jILi6EN1a1fEE1mEj.exit(0x40000001), %bb.4(0x3fffffff)
203 dead $wzr = SUBSWri killed $w8, 1, 0, implicit-def $nzcv
204 Bcc 1, %bb.4, implicit $nzcv
206 bb.2._ZN1jILi6EN1a1fEE1mEj.exit:
207 successors: %bb.5.sw.epilog(0x80000000)
210 $w2 = ORRWri $wzr, 0, implicit-def $x2
211 $x3 = IMPLICIT_DEF debug-location !32
213 STRXui $x2, $sp, 2 :: (store 8 into %ir.2)
214 DBG_VALUE 0, 0, !18, !23, debug-location !24
215 STRXui $x2, $sp, 0, debug-location !27 :: (store 8 into %ir.1)
216 $w4 = ORRWri $wzr, 0, implicit-def $x4
220 successors: %bb.5.sw.epilog(0x80000000)
223 $x4, $x3 = LDPXi $sp, 0 :: (dereferenceable load 8 from %ir.3), (dereferenceable load 8 from %ir..phi.trans.insert26)
224 $x2, $x1 = LDPXi $sp, 2 :: (dereferenceable load 8 from %ir..phi.trans.insert), (dereferenceable load 8 from %ir.4)
228 successors: %bb.5.sw.epilog(0x80000000)
231 $x2 = ORRXrs $xzr, $xzr, 0
232 $x4 = ORRXrs $xzr, $xzr, 0
233 $x3 = IMPLICIT_DEF debug-location !32
237 liveins: $x0, $x1, $x2, $x3, $x4
239 $w8 = LDRBBui $x0, 5 :: (load 1 from %ir.bx)
240 $w0 = LDRWui killed $x0, 0 :: (load 4 from %ir.bw1)
241 $x7 = ADRP target-flags(aarch64-page) @bt
242 $x7 = ADDXri killed $x7, target-flags(aarch64-pageoff, aarch64-nc) @bt, 0
243 dead $wzr = SUBSWri killed $w8, 0, 0, implicit-def $nzcv
244 $w5 = CSINCWr $wzr, $wzr, 0, implicit killed $nzcv
245 $w6 = ORRWrs $wzr, $wzr, 0
246 BL @_Z2byi1LS_bbPi, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit killed $x1, implicit killed $x2, implicit killed $x3, implicit killed $x4, implicit killed $w5, implicit killed $w6, implicit killed $x7, implicit-def $sp
247 $lr = LDRXui $sp, 4 :: (load 8 from %stack.2)
248 $sp = ADDXri $sp, 48, 0