182 lines · plain
1; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t2; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s3; CHECK: [[TYPE:.*]]: DW_TAG_structure_type4; Make sure we correctly handle containing type of a struct being a type identifier.5; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]} "C")6; CHECK-NEXT: DW_AT_name {{.*}}"C"7 8; Make sure we correctly handle context of a subprogram being a type identifier.9; CHECK: [[SP:.*]]: DW_TAG_subprogram10; CHECK: DW_AT_name {{.*}}"foo"11; Make sure we correctly handle containing type of a subprogram being a type identifier.12; CHECK: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]} "C")13; CHECK: DW_TAG_formal_parameter14; CHECK: NULL15; CHECK: NULL16 17; CHECK: [[TYPE2:.*]]: DW_TAG_structure_type18; CHECK: DW_AT_name {{.*}}"bar"19; CHECK: DW_TAG_structure_type20; CHECK: DW_AT_name {{.*}}"D"21; CHECK: DW_TAG_member22; CHECK: DW_AT_name {{.*}}"a"23; Make sure we correctly handle context of a struct being a type identifier.24; CHECK: DW_TAG_structure_type25; CHECK-NEXT: DW_AT_name {{.*}}"Nested"26; CHECK: DW_TAG_structure_type27; CHECK-NEXT: DW_AT_name {{.*}}"Nested2"28; CHECK-NEXT: DW_AT_declaration [DW_FORM_flag] (0x01)29; CHECK: DW_TAG_structure_type30; CHECK-NEXT: DW_AT_name {{.*}}"virt<bar>"31; Make sure we correctly handle type of a template_type being a type identifier.32; CHECK: DW_TAG_template_type_parameter33; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}34; CHECK-NEXT: DW_AT_name {{.*}}"T"35; Make sure we correctly handle derived-from of a typedef being a type identifier.36; CHECK: DW_TAG_typedef37; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}38; CHECK: DW_AT_name {{.*}}"baz2"39; Make sure we correctly handle derived-from of a pointer type being a type identifier.40; CHECK: DW_TAG_pointer_type41; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}42; CHECK: DW_TAG_typedef43; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}44; CHECK: DW_AT_name {{.*}}"baz"45; Make sure we correctly handle derived-from of an array type being a type identifier.46; CHECK: DW_TAG_array_type47; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]}48; IR generated from clang -g with the following source:49; struct C {50; virtual void foo();51; };52; void C::foo() {53; }54;55; struct bar { };56; typedef bar baz;57; struct D {58; typedef bar baz2;59; static int a;60; struct Nested { };61; struct Nested2 { };62; template <typename T>63; struct virt {64; T* values;65; };66; };67; void test() {68; baz B;69; bar A[3];70; D::baz2 B2;71; D::Nested e;72; D::Nested2 *p;73; D::virt<bar> t;74; }75 76%struct.C = type { ptr }77%struct.bar = type { i8 }78%"struct.D::Nested" = type { i8 }79%"struct.D::Nested2" = type { i8 }80%"struct.D::virt" = type { ptr }81 82@_ZTV1C = unnamed_addr constant [3 x ptr] [ptr null, ptr @_ZTI1C, ptr @_ZN1C3fooEv]83@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr84@_ZTS1C = constant [3 x i8] c"1C\00"85@_ZTI1C = unnamed_addr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1C }86 87; Function Attrs: nounwind ssp uwtable88define void @_ZN1C3fooEv(ptr %this) unnamed_addr #0 align 2 !dbg !31 {89entry:90 %this.addr = alloca ptr, align 891 store ptr %this, ptr %this.addr, align 892 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !36, metadata !DIExpression()), !dbg !3893 %this1 = load ptr, ptr %this.addr94 ret void, !dbg !3995}96 97; Function Attrs: nounwind readnone98declare void @llvm.dbg.declare(metadata, metadata, metadata) #199 100; Function Attrs: nounwind ssp uwtable101define void @_Z4testv() #0 !dbg !32 {102entry:103 %B = alloca %struct.bar, align 1104 %A = alloca [3 x %struct.bar], align 1105 %B2 = alloca %struct.bar, align 1106 %e = alloca %"struct.D::Nested", align 1107 %p = alloca ptr, align 8108 %t = alloca %"struct.D::virt", align 8109 call void @llvm.dbg.declare(metadata ptr %B, metadata !40, metadata !DIExpression()), !dbg !42110 call void @llvm.dbg.declare(metadata ptr %A, metadata !43, metadata !DIExpression()), !dbg !47111 call void @llvm.dbg.declare(metadata ptr %B2, metadata !48, metadata !DIExpression()), !dbg !50112 call void @llvm.dbg.declare(metadata ptr %e, metadata !51, metadata !DIExpression()), !dbg !52113 call void @llvm.dbg.declare(metadata ptr %p, metadata !53, metadata !DIExpression()), !dbg !55114 call void @llvm.dbg.declare(metadata ptr %t, metadata !56, metadata !DIExpression()), !dbg !57115 ret void, !dbg !58116}117 118attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }119attributes #1 = { nounwind readnone }120 121!llvm.dbg.cu = !{!0}122!llvm.module.flags = !{!35, !59}123 124!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)125!1 = !DIFile(filename: "tmp.cpp", directory: ".")126!2 = !{}127!3 = !{!4, !18, !19, !22, !23, !24}128!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, file: !1, elements: !5, vtableHolder: !4, identifier: "_ZTS1C")129!5 = !{!6, !13}130!6 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C", flags: DIFlagArtificial, file: !1, scope: !7, baseType: !8)131!7 = !DIFile(filename: "tmp.cpp", directory: ".")132!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !9)133!9 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", size: 64, baseType: !10)134!10 = !DISubroutineType(types: !11)135!11 = !{!12}136!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)137!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)138!14 = !DISubroutineType(types: !15)139!15 = !{null, !16}140!16 = !DIDerivedType(tag: DW_TAG_pointer_type, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)141!18 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 7, size: 8, align: 8, file: !1, elements: !2, identifier: "_ZTS3bar")142!19 = !DICompositeType(tag: DW_TAG_structure_type, name: "D", line: 9, size: 8, align: 8, file: !1, elements: !20, identifier: "_ZTS1D")143!20 = !{!21}144!21 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 11, flags: DIFlagStaticMember, file: !1, scope: !19, baseType: !12)145!22 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", line: 12, size: 8, align: 8, file: !1, scope: !19, elements: !2, identifier: "_ZTSN1D6NestedE")146!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested2", line: 13, flags: DIFlagFwdDecl, file: !1, scope: !19, identifier: "_ZTSN1D7Nested2E")147!24 = !DICompositeType(tag: DW_TAG_structure_type, name: "virt<bar>", line: 15, file: !1, scope: !19, elements: !25, templateParams: !28, identifier: "_ZTSN1D4virtI3barEE")148!25 = !{!26}149!26 = !DIDerivedType(tag: DW_TAG_member, name: "values", line: 16, size: 64, align: 64, file: !1, scope: !24, baseType: !27)150!27 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !18)151!28 = !{!29}152!29 = !DITemplateTypeParameter(name: "T", type: !18)153!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, retainedNodes: !2)154!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, retainedNodes: !2)155!33 = !DISubroutineType(types: !34)156!34 = !{null}157!35 = !{i32 2, !"Dwarf Version", i32 3}158!36 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !31, type: !37)159!37 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !4)160!38 = !DILocation(line: 0, scope: !31)161!39 = !DILocation(line: 5, scope: !31)162!40 = !DILocalVariable(name: "B", line: 21, scope: !32, file: !7, type: !41)163!41 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", line: 8, file: !1, baseType: !18)164!42 = !DILocation(line: 21, scope: !32)165!43 = !DILocalVariable(name: "A", line: 22, scope: !32, file: !7, type: !44)166!44 = !DICompositeType(tag: DW_TAG_array_type, size: 24, align: 8, baseType: !18, elements: !45)167!45 = !{!46}168!46 = !DISubrange(count: 3)169!47 = !DILocation(line: 22, scope: !32)170!48 = !DILocalVariable(name: "B2", line: 23, scope: !32, file: !7, type: !49)171!49 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz2", line: 10, file: !1, scope: !19, baseType: !18)172!50 = !DILocation(line: 23, scope: !32)173!51 = !DILocalVariable(name: "e", line: 24, scope: !32, file: !7, type: !22)174!52 = !DILocation(line: 24, scope: !32)175!53 = !DILocalVariable(name: "p", line: 25, scope: !32, file: !7, type: !54)176!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23)177!55 = !DILocation(line: 25, scope: !32)178!56 = !DILocalVariable(name: "t", line: 26, scope: !32, file: !7, type: !24)179!57 = !DILocation(line: 26, scope: !32)180!58 = !DILocation(line: 27, scope: !32)181!59 = !{i32 1, !"Debug Info Version", i32 3}182