1*9880d681SAndroid Build Coastguard Worker; REQUIRES: object-emission 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t 4*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s 5*9880d681SAndroid Build Coastguard Worker; CHECK: [[TYPE:.*]]: DW_TAG_structure_type 6*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle containing type of a struct being a type identifier. 7*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}) 8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "C") 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle context of a subprogram being a type identifier. 11*9880d681SAndroid Build Coastguard Worker; CHECK: [[SP:.*]]: DW_TAG_subprogram 12*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "foo") 13*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle containing type of a subprogram being a type identifier. 14*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}) 15*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter 16*9880d681SAndroid Build Coastguard Worker; CHECK: NULL 17*9880d681SAndroid Build Coastguard Worker; CHECK: NULL 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker; CHECK: [[TYPE2:.*]]: DW_TAG_structure_type 20*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "bar") 21*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_structure_type 22*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "D") 23*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_member 24*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "a") 25*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle context of a struct being a type identifier. 26*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_structure_type 27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested") 28*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_structure_type 29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested2") 30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_declaration [DW_FORM_flag] (0x01) 31*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_structure_type 32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "virt<bar>") 33*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle type of a template_type being a type identifier. 34*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_template_type_parameter 35*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}) 36*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "T") 37*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle derived-from of a typedef being a type identifier. 38*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_typedef 39*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}) 40*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz2") 41*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle derived-from of a pointer type being a type identifier. 42*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_pointer_type 43*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}) 44*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_typedef 45*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}) 46*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz") 47*9880d681SAndroid Build Coastguard Worker; Make sure we correctly handle derived-from of an array type being a type identifier. 48*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_array_type 49*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}) 50*9880d681SAndroid Build Coastguard Worker; IR generated from clang -g with the following source: 51*9880d681SAndroid Build Coastguard Worker; struct C { 52*9880d681SAndroid Build Coastguard Worker; virtual void foo(); 53*9880d681SAndroid Build Coastguard Worker; }; 54*9880d681SAndroid Build Coastguard Worker; void C::foo() { 55*9880d681SAndroid Build Coastguard Worker; } 56*9880d681SAndroid Build Coastguard Worker; 57*9880d681SAndroid Build Coastguard Worker; struct bar { }; 58*9880d681SAndroid Build Coastguard Worker; typedef bar baz; 59*9880d681SAndroid Build Coastguard Worker; struct D { 60*9880d681SAndroid Build Coastguard Worker; typedef bar baz2; 61*9880d681SAndroid Build Coastguard Worker; static int a; 62*9880d681SAndroid Build Coastguard Worker; struct Nested { }; 63*9880d681SAndroid Build Coastguard Worker; struct Nested2 { }; 64*9880d681SAndroid Build Coastguard Worker; template <typename T> 65*9880d681SAndroid Build Coastguard Worker; struct virt { 66*9880d681SAndroid Build Coastguard Worker; T* values; 67*9880d681SAndroid Build Coastguard Worker; }; 68*9880d681SAndroid Build Coastguard Worker; }; 69*9880d681SAndroid Build Coastguard Worker; void test() { 70*9880d681SAndroid Build Coastguard Worker; baz B; 71*9880d681SAndroid Build Coastguard Worker; bar A[3]; 72*9880d681SAndroid Build Coastguard Worker; D::baz2 B2; 73*9880d681SAndroid Build Coastguard Worker; D::Nested e; 74*9880d681SAndroid Build Coastguard Worker; D::Nested2 *p; 75*9880d681SAndroid Build Coastguard Worker; D::virt<bar> t; 76*9880d681SAndroid Build Coastguard Worker; } 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Worker%struct.C = type { i32 (...)** } 79*9880d681SAndroid Build Coastguard Worker%struct.bar = type { i8 } 80*9880d681SAndroid Build Coastguard Worker%"struct.D::Nested" = type { i8 } 81*9880d681SAndroid Build Coastguard Worker%"struct.D::Nested2" = type { i8 } 82*9880d681SAndroid Build Coastguard Worker%"struct.D::virt" = type { %struct.bar* } 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker@_ZTV1C = unnamed_addr constant [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1C to i8*), i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)] 85*9880d681SAndroid Build Coastguard Worker@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* 86*9880d681SAndroid Build Coastguard Worker@_ZTS1C = constant [3 x i8] c"1C\00" 87*9880d681SAndroid Build Coastguard Worker@_ZTI1C = unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1C, i32 0, i32 0) } 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind ssp uwtable 90*9880d681SAndroid Build Coastguard Workerdefine void @_ZN1C3fooEv(%struct.C* %this) unnamed_addr #0 align 2 !dbg !31 { 91*9880d681SAndroid Build Coastguard Workerentry: 92*9880d681SAndroid Build Coastguard Worker %this.addr = alloca %struct.C*, align 8 93*9880d681SAndroid Build Coastguard Worker store %struct.C* %this, %struct.C** %this.addr, align 8 94*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !36, metadata !DIExpression()), !dbg !38 95*9880d681SAndroid Build Coastguard Worker %this1 = load %struct.C*, %struct.C** %this.addr 96*9880d681SAndroid Build Coastguard Worker ret void, !dbg !39 97*9880d681SAndroid Build Coastguard Worker} 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 100*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1 101*9880d681SAndroid Build Coastguard Worker 102*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind ssp uwtable 103*9880d681SAndroid Build Coastguard Workerdefine void @_Z4testv() #0 !dbg !32 { 104*9880d681SAndroid Build Coastguard Workerentry: 105*9880d681SAndroid Build Coastguard Worker %B = alloca %struct.bar, align 1 106*9880d681SAndroid Build Coastguard Worker %A = alloca [3 x %struct.bar], align 1 107*9880d681SAndroid Build Coastguard Worker %B2 = alloca %struct.bar, align 1 108*9880d681SAndroid Build Coastguard Worker %e = alloca %"struct.D::Nested", align 1 109*9880d681SAndroid Build Coastguard Worker %p = alloca %"struct.D::Nested2"*, align 8 110*9880d681SAndroid Build Coastguard Worker %t = alloca %"struct.D::virt", align 8 111*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %struct.bar* %B, metadata !40, metadata !DIExpression()), !dbg !42 112*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata [3 x %struct.bar]* %A, metadata !43, metadata !DIExpression()), !dbg !47 113*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %struct.bar* %B2, metadata !48, metadata !DIExpression()), !dbg !50 114*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %"struct.D::Nested"* %e, metadata !51, metadata !DIExpression()), !dbg !52 115*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %"struct.D::Nested2"** %p, metadata !53, metadata !DIExpression()), !dbg !55 116*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata %"struct.D::virt"* %t, metadata !56, metadata !DIExpression()), !dbg !57 117*9880d681SAndroid Build Coastguard Worker ret void, !dbg !58 118*9880d681SAndroid Build Coastguard Worker} 119*9880d681SAndroid Build Coastguard Worker 120*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 121*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone } 122*9880d681SAndroid Build Coastguard Worker 123*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 124*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!35, !59} 125*9880d681SAndroid Build Coastguard Worker 126*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2) 127*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "tmp.cpp", directory: ".") 128*9880d681SAndroid Build Coastguard Worker!2 = !{} 129*9880d681SAndroid Build Coastguard Worker!3 = !{!4, !18, !19, !22, !23, !24} 130*9880d681SAndroid Build Coastguard Worker!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, file: !1, elements: !5, vtableHolder: !4, identifier: "_ZTS1C") 131*9880d681SAndroid Build Coastguard Worker!5 = !{!6, !13} 132*9880d681SAndroid Build Coastguard Worker!6 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C", flags: DIFlagArtificial, file: !1, scope: !7, baseType: !8) 133*9880d681SAndroid Build Coastguard Worker!7 = !DIFile(filename: "tmp.cpp", directory: ".") 134*9880d681SAndroid Build Coastguard Worker!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !9) 135*9880d681SAndroid Build Coastguard Worker!9 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", size: 64, baseType: !10) 136*9880d681SAndroid Build Coastguard Worker!10 = !DISubroutineType(types: !11) 137*9880d681SAndroid Build Coastguard Worker!11 = !{!12} 138*9880d681SAndroid Build Coastguard Worker!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 139*9880d681SAndroid Build Coastguard Worker!13 = !DISubprogram(name: "foo", linkageName: "_ZN1C3fooEv", line: 2, isLocal: false, isDefinition: false, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !4, type: !14, containingType: !4) 140*9880d681SAndroid Build Coastguard Worker!14 = !DISubroutineType(types: !15) 141*9880d681SAndroid Build Coastguard Worker!15 = !{null, !16} 142*9880d681SAndroid Build Coastguard Worker!16 = !DIDerivedType(tag: DW_TAG_pointer_type, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4) 143*9880d681SAndroid Build Coastguard Worker!18 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 7, size: 8, align: 8, file: !1, elements: !2, identifier: "_ZTS3bar") 144*9880d681SAndroid Build Coastguard Worker!19 = !DICompositeType(tag: DW_TAG_structure_type, name: "D", line: 9, size: 8, align: 8, file: !1, elements: !20, identifier: "_ZTS1D") 145*9880d681SAndroid Build Coastguard Worker!20 = !{!21} 146*9880d681SAndroid Build Coastguard Worker!21 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 11, flags: DIFlagStaticMember, file: !1, scope: !19, baseType: !12) 147*9880d681SAndroid Build Coastguard Worker!22 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", line: 12, size: 8, align: 8, file: !1, scope: !19, elements: !2, identifier: "_ZTSN1D6NestedE") 148*9880d681SAndroid Build Coastguard Worker!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested2", line: 13, flags: DIFlagFwdDecl, file: !1, scope: !19, identifier: "_ZTSN1D7Nested2E") 149*9880d681SAndroid Build Coastguard Worker!24 = !DICompositeType(tag: DW_TAG_structure_type, name: "virt<bar>", line: 15, file: !1, scope: !19, elements: !25, templateParams: !28, identifier: "_ZTSN1D4virtI3barEE") 150*9880d681SAndroid Build Coastguard Worker!25 = !{!26} 151*9880d681SAndroid Build Coastguard Worker!26 = !DIDerivedType(tag: DW_TAG_member, name: "values", line: 16, size: 64, align: 64, file: !1, scope: !24, baseType: !27) 152*9880d681SAndroid Build Coastguard Worker!27 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !18) 153*9880d681SAndroid Build Coastguard Worker!28 = !{!29} 154*9880d681SAndroid Build Coastguard Worker!29 = !DITemplateTypeParameter(name: "T", type: !18) 155*9880d681SAndroid Build Coastguard Worker!31 = distinct !DISubprogram(name: "foo", linkageName: "_ZN1C3fooEv", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !1, scope: null, type: !14, declaration: !13, variables: !2) 156*9880d681SAndroid Build Coastguard Worker!32 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", line: 20, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 20, file: !1, scope: !7, type: !33, variables: !2) 157*9880d681SAndroid Build Coastguard Worker!33 = !DISubroutineType(types: !34) 158*9880d681SAndroid Build Coastguard Worker!34 = !{null} 159*9880d681SAndroid Build Coastguard Worker!35 = !{i32 2, !"Dwarf Version", i32 2} 160*9880d681SAndroid Build Coastguard Worker!36 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !31, type: !37) 161*9880d681SAndroid Build Coastguard Worker!37 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !4) 162*9880d681SAndroid Build Coastguard Worker!38 = !DILocation(line: 0, scope: !31) 163*9880d681SAndroid Build Coastguard Worker!39 = !DILocation(line: 5, scope: !31) 164*9880d681SAndroid Build Coastguard Worker!40 = !DILocalVariable(name: "B", line: 21, scope: !32, file: !7, type: !41) 165*9880d681SAndroid Build Coastguard Worker!41 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", line: 8, file: !1, baseType: !18) 166*9880d681SAndroid Build Coastguard Worker!42 = !DILocation(line: 21, scope: !32) 167*9880d681SAndroid Build Coastguard Worker!43 = !DILocalVariable(name: "A", line: 22, scope: !32, file: !7, type: !44) 168*9880d681SAndroid Build Coastguard Worker!44 = !DICompositeType(tag: DW_TAG_array_type, size: 24, align: 8, baseType: !18, elements: !45) 169*9880d681SAndroid Build Coastguard Worker!45 = !{!46} 170*9880d681SAndroid Build Coastguard Worker!46 = !DISubrange(count: 3) 171*9880d681SAndroid Build Coastguard Worker!47 = !DILocation(line: 22, scope: !32) 172*9880d681SAndroid Build Coastguard Worker!48 = !DILocalVariable(name: "B2", line: 23, scope: !32, file: !7, type: !49) 173*9880d681SAndroid Build Coastguard Worker!49 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz2", line: 10, file: !1, scope: !19, baseType: !18) 174*9880d681SAndroid Build Coastguard Worker!50 = !DILocation(line: 23, scope: !32) 175*9880d681SAndroid Build Coastguard Worker!51 = !DILocalVariable(name: "e", line: 24, scope: !32, file: !7, type: !22) 176*9880d681SAndroid Build Coastguard Worker!52 = !DILocation(line: 24, scope: !32) 177*9880d681SAndroid Build Coastguard Worker!53 = !DILocalVariable(name: "p", line: 25, scope: !32, file: !7, type: !54) 178*9880d681SAndroid Build Coastguard Worker!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23) 179*9880d681SAndroid Build Coastguard Worker!55 = !DILocation(line: 25, scope: !32) 180*9880d681SAndroid Build Coastguard Worker!56 = !DILocalVariable(name: "t", line: 26, scope: !32, file: !7, type: !24) 181*9880d681SAndroid Build Coastguard Worker!57 = !DILocation(line: 26, scope: !32) 182*9880d681SAndroid Build Coastguard Worker!58 = !DILocation(line: 27, scope: !32) 183*9880d681SAndroid Build Coastguard Worker!59 = !{i32 1, !"Debug Info Version", i32 3} 184