1# RUN: llc -emit-call-site-info -start-after=livedebugvalues -filetype=obj -o - %s \ 2# RUN: | llvm-dwarfdump -v - | FileCheck %s 3 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. 6 7# CHECK: .debug_info contents: 8# CHECK: DW_TAG_formal_parameter [14] 9# CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (0) 10# CHECK-NEXT: DW_AT_abstract_origin {{.*}} "name" 11--- | 12 ; ModuleID = 't.ll' 13 source_filename = "t.ll" 14 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 15 target triple = "aarch64--linux-gnu" 16 17 %class.v = type <{ i32, i8, i8, [2 x i8] }> 18 %class.j = type <{ %"class.j<6, a::f>::D", i32, [4 x i8] }> 19 %"class.j<6, a::f>::D" = type { %"class.j<6, a::f>::p" } 20 %"class.j<6, a::f>::p" = type { i64 } 21 22 @bt = global i32 0, align 4 23 24 define void @_ZN1v2bvEv(%class.v* nocapture readonly %this) local_unnamed_addr align 2 !dbg !14 { 25 entry: 26 %bz = alloca %class.j, align 8 27 %att = alloca %class.j, align 8 28 %ap = getelementptr inbounds %class.v, %class.v* %this, i64 0, i32 1 29 %0 = load i8, i8* %ap, align 4 30 %conv = sext i8 %0 to i32 31 switch i32 %conv, label %sw.epilog [ 32 i32 1, label %_ZN1jILi6EN1a1fEE1mEj.exit 33 i32 0, label %sw.bb2 34 ] 35 36 _ZN1jILi6EN1a1fEE1mEj.exit: ; preds = %entry 37 %1 = bitcast %class.j* %att to i64* 38 %2 = bitcast %class.j* %bz to i64* 39 store i64 1, i64* %2, align 8 40 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !18, metadata !23), !dbg !24 41 store i64 1, i64* %1, align 8, !dbg !27 42 br label %sw.epilog 43 44 sw.bb2: ; preds = %entry 45 %3 = bitcast %class.j* %att to i64* 46 %4 = bitcast %class.j* %bz to i64* 47 %.pre = load i64, i64* %3, align 8 48 %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 49 %.phi.trans.insert = bitcast i32* %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i13.phi.trans.insert to i64* 50 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14.pre = load i64, i64* %.phi.trans.insert, align 8 51 %.pre25 = load i64, i64* %4, align 8 52 %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 53 %.phi.trans.insert26 = bitcast i32* %agg.tmp.sroa.2.0..sroa_idx1.i.i.i.i.i.i.phi.trans.insert to i64* 54 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i.pre = load i64, i64* %.phi.trans.insert26, align 8 55 br label %sw.epilog 56 57 sw.epilog: ; preds = %sw.bb2, %_ZN1jILi6EN1a1fEE1mEj.exit, %entry 58 %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 59 %5 = phi i64 [ %.pre25, %sw.bb2 ], [ 0, %entry ], [ 1, %_ZN1jILi6EN1a1fEE1mEj.exit ] 60 %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 ] 61 %6 = phi i64 [ %.pre, %sw.bb2 ], [ 0, %entry ], [ 1, %_ZN1jILi6EN1a1fEE1mEj.exit ] 62 %bw1 = bitcast %class.v* %this to i32* 63 %7 = load i32, i32* %bw1, align 4 64 %bx = getelementptr inbounds %class.v, %class.v* %this, i64 0, i32 2 65 %8 = load i8, i8* %bx, align 1 66 %tobool = icmp ne i8 %8, 0 67 %.fca.0.insert9 = insertvalue [2 x i64] undef, i64 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i14, 0 68 %.fca.1.insert12 = insertvalue [2 x i64] %.fca.0.insert9, i64 %5, 1 69 %.fca.0.insert = insertvalue [2 x i64] undef, i64 %agg.tmp.sroa.2.0.copyload2.i.i6.i.i.i.i, 0 70 %.fca.1.insert = insertvalue [2 x i64] %.fca.0.insert, i64 %6, 1 71 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) 72 ret void 73 } 74 75 declare void @_Z2byi1LS_bbPi(i32, [2 x i64], [2 x i64], i1, i1, i32*) local_unnamed_addr 76 77 ; Function Attrs: nounwind readnone speculatable 78 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #0 79 80 ; Function Attrs: nounwind 81 declare void @llvm.stackprotector(i8*, i8**) #1 82 83 attributes #0 = { nounwind readnone speculatable } 84 attributes #1 = { nounwind } 85 86 !llvm.dbg.cu = !{!0} 87 !llvm.module.flags = !{!12, !13} 88 89 !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) 90 !1 = !DIFile(filename: "/<stdin>", directory: "/") 91 !2 = !{} 92 !3 = !{!4, !10} 93 !4 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "r", file: !5, line: 50, size: 8, elements: !6, identifier: "_ZTS1r") 94 !5 = !DIFile(filename: "current.ii", directory: "/") 95 !6 = !{!7} 96 !7 = !DISubprogram(name: "r", scope: !4, file: !5, line: 52, type: !8, isLocal: false, isDefinition: false, scopeLine: 52, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true) 97 !8 = !DISubroutineType(types: !9) 98 !9 = !{null} 99 !10 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "q", scope: !11, file: !5, line: 39, size: 64, elements: !2, identifier: "_ZTSN1jILi6EN1a1fEE1qE") 100 !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") 101 !12 = !{i32 2, !"Debug Info Version", i32 3} 102 !13 = !{i32 1, !"wchar_size", i32 4} 103 !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) 104 !15 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "v", file: !5, line: 97, size: 64, elements: !2, identifier: "_ZTS1v") 105 !16 = !DISubroutineType(types: !2) 106 !17 = !DISubprogram(name: "bv", linkageName: "_ZN1v2bvEv", scope: !15, file: !5, line: 98, type: !16, isLocal: false, isDefinition: false, scopeLine: 98, flags: DIFlagPrototyped, isOptimized: true) 107 !18 = !DILocalVariable(name: "name", arg: 2, scope: !19, file: !5, line: 22, type: !21) 108 !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) 109 !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) 110 !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "h", file: !5, line: 10, baseType: !22) 111 !22 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) 112 !23 = !DIExpression() 113 !24 = !DILocation(line: 22, scope: !19, inlinedAt: !25) 114 !25 = distinct !DILocation(line: 109, scope: !26) 115 !26 = distinct !DILexicalBlock(scope: !14, file: !5, line: 106) 116 !27 = !DILocation(line: 29, scope: !28, inlinedAt: !31) 117 !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) 118 !29 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "p", scope: !11, file: !5, line: 26, size: 64, elements: !2, identifier: "_ZTSN1jILi6EN1a1fEE1pE") 119 !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) 120 !31 = distinct !DILocation(line: 24, scope: !19, inlinedAt: !25) 121 !32 = !DILocation(line: 61, scope: !33, inlinedAt: !38) 122 !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) 123 !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !5, line: 59, size: 8, elements: !2, identifier: "_ZTS1s") 124 !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) 125 !36 = !{!37} 126 !37 = !DITemplateTypeParameter(name: "ay", type: !11) 127 !38 = distinct !DILocation(line: 70, scope: !39, inlinedAt: !42) 128 !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) 129 !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") 130 !41 = !DISubprogram(name: "bc", linkageName: "_ZN1JI1s1jILi6EN1a1fEEE2bcEPS4_", scope: !40, file: !5, line: 70, type: !16, isLocal: false, isDefinition: false, scopeLine: 70, flags: DIFlagPrototyped, isOptimized: true) 131 !42 = distinct !DILocation(line: 85, scope: !43, inlinedAt: !46) 132 !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) 133 !44 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "u", file: !5, line: 82, size: 128, elements: !2, identifier: "_ZTS1u") 134 !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) 135 !46 = distinct !DILocation(line: 85, scope: !47, inlinedAt: !48) 136 !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) 137 !48 = distinct !DILocation(line: 92, scope: !49, inlinedAt: !52) 138 !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) 139 !50 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "L", file: !5, line: 88, size: 128, elements: !2, identifier: "_ZTS1L") 140 !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) 141 !52 = distinct !DILocation(line: 92, scope: !53, inlinedAt: !54) 142 !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) 143 !54 = distinct !DILocation(line: 114, scope: !14) 144 145... 146--- 147name: _ZN1v2bvEv 148alignment: 4 149exposesReturnsTwice: false 150legalized: false 151regBankSelected: false 152selected: false 153tracksRegLiveness: true 154registers: 155liveins: 156 - { reg: '$x0', virtual-reg: '' } 157frameInfo: 158 isFrameAddressTaken: false 159 isReturnAddressTaken: false 160 hasStackMap: false 161 hasPatchPoint: false 162 stackSize: 48 163 offsetAdjustment: 0 164 maxAlignment: 16 165 adjustsStack: true 166 hasCalls: true 167 stackProtector: '' 168 maxCallFrameSize: 0 169 hasOpaqueSPAdjustment: false 170 hasVAStart: false 171 hasMustTailInVarArgFunc: false 172 savePoint: '' 173 restorePoint: '' 174fixedStack: 175stack: 176 - { id: 0, name: bz, type: default, offset: -32, size: 16, alignment: 8, 177 callee-saved-register: '', local-offset: -16, debug-info-variable: '', 178 debug-info-expression: '', debug-info-location: '' } 179 - { id: 1, name: att, type: default, offset: -48, size: 16, alignment: 8, 180 callee-saved-register: '', local-offset: -32, debug-info-variable: '', 181 debug-info-expression: '', debug-info-location: '' } 182 - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16, 183 callee-saved-register: '$lr', debug-info-variable: '', 184 debug-info-expression: '', debug-info-location: '' } 185constants: 186body: | 187 bb.0.entry: 188 successors: %bb.3.sw.bb2(0x2aaaaaab), %bb.1.entry(0x55555555) 189 liveins: $x0, $lr 190 191 $sp = frame-setup SUBXri $sp, 48, 0 192 frame-setup STRXui killed $lr, $sp, 4 :: (store 8 into %stack.2) 193 frame-setup CFI_INSTRUCTION def_cfa_offset 48 194 frame-setup CFI_INSTRUCTION offset $w30, -16 195 $w8 = LDRSBWui $x0, 4 :: (load 1 from %ir.ap, align 4) 196 CBZW $w8, %bb.3.sw.bb2 197 198 bb.1.entry: 199 successors: %bb.2._ZN1jILi6EN1a1fEE1mEj.exit(0x40000001), %bb.4(0x3fffffff) 200 liveins: $w8, $x0 201 202 dead $wzr = SUBSWri killed $w8, 1, 0, implicit-def $nzcv 203 Bcc 1, %bb.4, implicit $nzcv 204 205 bb.2._ZN1jILi6EN1a1fEE1mEj.exit: 206 successors: %bb.5.sw.epilog(0x80000000) 207 liveins: $x0 208 209 $w2 = ORRWri $wzr, 0, implicit-def $x2 210 $x3 = IMPLICIT_DEF debug-location !32 211 $x1 = IMPLICIT_DEF 212 STRXui $x2, $sp, 2 :: (store 8 into %ir.2) 213 DBG_VALUE 0, 0, !18, !23, debug-location !24 214 STRXui $x2, $sp, 0, debug-location !27 :: (store 8 into %ir.1) 215 $w4 = ORRWri $wzr, 0, implicit-def $x4 216 B %bb.5.sw.epilog 217 218 bb.3.sw.bb2: 219 successors: %bb.5.sw.epilog(0x80000000) 220 liveins: $x0 221 222 $x4, $x3 = LDPXi $sp, 0 :: (dereferenceable load 8 from %ir.3), (dereferenceable load 8 from %ir..phi.trans.insert26) 223 $x2, $x1 = LDPXi $sp, 2 :: (dereferenceable load 8 from %ir..phi.trans.insert), (dereferenceable load 8 from %ir.4) 224 B %bb.5.sw.epilog 225 226 bb.4: 227 successors: %bb.5.sw.epilog(0x80000000) 228 liveins: $x0 229 230 $x2 = ORRXrs $xzr, $xzr, 0 231 $x4 = ORRXrs $xzr, $xzr, 0 232 $x3 = IMPLICIT_DEF debug-location !32 233 $x1 = IMPLICIT_DEF 234 235 bb.5.sw.epilog: 236 liveins: $x0, $x1, $x2, $x3, $x4 237 238 $w8 = LDRBBui $x0, 5 :: (load 1 from %ir.bx) 239 $w0 = LDRWui killed $x0, 0 :: (load 4 from %ir.bw1) 240 $x7 = ADRP target-flags(aarch64-page) @bt 241 $x7 = ADDXri killed $x7, target-flags(aarch64-pageoff, aarch64-nc) @bt, 0 242 dead $wzr = SUBSWri killed $w8, 0, 0, implicit-def $nzcv 243 $w5 = CSINCWr $wzr, $wzr, 0, implicit killed $nzcv 244 $w6 = ORRWrs $wzr, $wzr, 0 245 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 246 $lr = LDRXui $sp, 4 :: (load 8 from %stack.2) 247 $sp = ADDXri $sp, 48, 0 248 RET undef $lr 249 250... 251