Home | History | Annotate | Download | only in DebugInfo
      1 ; REQUIRES: object-emission
      2 
      3 ; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t
      4 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
      5 ; CHECK: [[TYPE:.*]]: DW_TAG_structure_type
      6 ; Make sure we correctly handle containing type of a struct being a type identifier.
      7 ; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]})
      8 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "C")
      9 
     10 ; Make sure we correctly handle context of a subprogram being a type identifier.
     11 ; CHECK: [[SP:.*]]: DW_TAG_subprogram
     12 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "foo")
     13 ; Make sure we correctly handle containing type of a subprogram being a type identifier.
     14 ; CHECK: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]})
     15 ; CHECK: DW_TAG_formal_parameter
     16 ; CHECK: NULL
     17 ; CHECK: NULL
     18 
     19 ; CHECK: [[TYPE2:.*]]: DW_TAG_structure_type
     20 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "bar")
     21 ; CHECK: DW_TAG_structure_type
     22 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "D")
     23 ; CHECK: DW_TAG_member
     24 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "a") 
     25 ; Make sure we correctly handle context of a struct being a type identifier.
     26 ; CHECK: DW_TAG_structure_type
     27 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested")
     28 ; CHECK: DW_TAG_structure_type
     29 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "Nested2")
     30 ; CHECK-NEXT: DW_AT_declaration [DW_FORM_flag]      (0x01)
     31 ; CHECK: DW_TAG_structure_type
     32 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "virt<bar>")
     33 ; Make sure we correctly handle type of a template_type being a type identifier.
     34 ; CHECK: DW_TAG_template_type_parameter
     35 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]})
     36 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "T")
     37 ; Make sure we correctly handle derived-from of a typedef being a type identifier.
     38 ; CHECK: DW_TAG_typedef
     39 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]})
     40 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz2")
     41 ; Make sure we correctly handle derived-from of a pointer type being a type identifier.
     42 ; CHECK: DW_TAG_pointer_type
     43 ; CHECK: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
     44 ; CHECK: DW_TAG_typedef
     45 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]})
     46 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "baz")
     47 ; Make sure we correctly handle derived-from of an array type being a type identifier.
     48 ; CHECK: DW_TAG_array_type
     49 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE2]]})
     50 ; IR generated from clang -g with the following source:
     51 ; struct C {
     52 ;   virtual void foo();
     53 ; };
     54 ; void C::foo() {
     55 ; }
     56 ;
     57 ; struct bar { };
     58 ; typedef bar baz;
     59 ; struct D {
     60 ;   typedef bar baz2;
     61 ;   static int a;
     62 ;   struct Nested { };
     63 ;   struct Nested2 { };
     64 ;   template <typename T>
     65 ;   struct virt {
     66 ;     T* values;
     67 ;   };
     68 ; };
     69 ; void test() {
     70 ;   baz B;
     71 ;   bar A[3];
     72 ;   D::baz2 B2;
     73 ;   D::Nested e;
     74 ;   D::Nested2 *p;
     75 ;   D::virt<bar> t;
     76 ; }
     77 
     78 %struct.C = type { i32 (...)** }
     79 %struct.bar = type { i8 }
     80 %"struct.D::Nested" = type { i8 }
     81 %"struct.D::Nested2" = type { i8 }
     82 %"struct.D::virt" = type { %struct.bar* }
     83 
     84 @_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 @_ZTVN10__cxxabiv117__class_type_infoE = external global i8*
     86 @_ZTS1C = constant [3 x i8] c"1C\00"
     87 @_ZTI1C = unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8]* @_ZTS1C, i32 0, i32 0) }
     88 
     89 ; Function Attrs: nounwind ssp uwtable
     90 define void @_ZN1C3fooEv(%struct.C* %this) unnamed_addr #0 align 2 {
     91 entry:
     92   %this.addr = alloca %struct.C*, align 8
     93   store %struct.C* %this, %struct.C** %this.addr, align 8
     94   call void @llvm.dbg.declare(metadata !{%struct.C** %this.addr}, metadata !36), !dbg !38
     95   %this1 = load %struct.C** %this.addr
     96   ret void, !dbg !39
     97 }
     98 
     99 ; Function Attrs: nounwind readnone
    100 declare void @llvm.dbg.declare(metadata, metadata) #1
    101 
    102 ; Function Attrs: nounwind ssp uwtable
    103 define void @_Z4testv() #0 {
    104 entry:
    105   %B = alloca %struct.bar, align 1
    106   %A = alloca [3 x %struct.bar], align 1
    107   %B2 = alloca %struct.bar, align 1
    108   %e = alloca %"struct.D::Nested", align 1
    109   %p = alloca %"struct.D::Nested2"*, align 8
    110   %t = alloca %"struct.D::virt", align 8
    111   call void @llvm.dbg.declare(metadata !{%struct.bar* %B}, metadata !40), !dbg !42
    112   call void @llvm.dbg.declare(metadata !{[3 x %struct.bar]* %A}, metadata !43), !dbg !47
    113   call void @llvm.dbg.declare(metadata !{%struct.bar* %B2}, metadata !48), !dbg !50
    114   call void @llvm.dbg.declare(metadata !{%"struct.D::Nested"* %e}, metadata !51), !dbg !52
    115   call void @llvm.dbg.declare(metadata !{%"struct.D::Nested2"** %p}, metadata !53), !dbg !55
    116   call void @llvm.dbg.declare(metadata !{%"struct.D::virt"* %t}, metadata !56), !dbg !57
    117   ret void, !dbg !58
    118 }
    119 
    120 attributes #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 attributes #1 = { nounwind readnone }
    122 
    123 !llvm.dbg.cu = !{!0}
    124 !llvm.module.flags = !{!35, !59}
    125 
    126 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !30, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [tmp.cpp] [DW_LANG_C_plus_plus]
    127 !1 = metadata !{metadata !"tmp.cpp", metadata !"."}
    128 !2 = metadata !{}
    129 !3 = metadata !{metadata !4, metadata !18, metadata !19, metadata !22, metadata !23, metadata !24}
    130 !4 = metadata !{i32 786451, metadata !1, null, metadata !"C", i32 1, i64 64, i64 64, i32 0, i32 0, null, metadata !5, i32 0, metadata !"_ZTS1C", null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] [line 1, size 64, align 64, offset 0] [def] [from ]
    131 !5 = metadata !{metadata !6, metadata !13}
    132 !6 = metadata !{i32 786445, metadata !1, metadata !7, metadata !"_vptr$C", i32 0, i64 64, i64 0, i64 0, i32 64, metadata !8} ; [ DW_TAG_member ] [_vptr$C] [line 0, size 64, align 0, offset 0] [artificial] [from ]
    133 !7 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [tmp.cpp]
    134 !8 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 0, i64 0, i32 0, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 0, offset 0] [from __vtbl_ptr_type]
    135 !9 = metadata !{i32 786447, null, null, metadata !"__vtbl_ptr_type", i32 0, i64 64, i64 0, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [__vtbl_ptr_type] [line 0, size 64, align 0, offset 0] [from ]
    136 !10 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
    137 !11 = metadata !{metadata !12}
    138 !12 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
    139 !13 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 2, metadata !14, i1 false, i1 false, i32 1, i32 0, metadata !"_ZTS1C", i32 256, i1 false, null, null, i32 0, metadata !17, i32 2} ; [ DW_TAG_subprogram ] [line 2] [foo]
    140 !14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
    141 !15 = metadata !{null, metadata !16}
    142 !16 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1C"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1C]
    143 !17 = metadata !{i32 786468}
    144 !18 = metadata !{i32 786451, metadata !1, null, metadata !"bar", i32 7, i64 8, i64 8, i32 0, i32 0, null, metadata !2, i32 0, null, null, metadata !"_ZTS3bar"} ; [ DW_TAG_structure_type ] [bar] [line 7, size 8, align 8, offset 0] [def] [from ]
    145 !19 = metadata !{i32 786451, metadata !1, null, metadata !"D", i32 9, i64 8, i64 8, i32 0, i32 0, null, metadata !20, i32 0, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] [line 9, size 8, align 8, offset 0] [def] [from ]
    146 !20 = metadata !{metadata !21}
    147 !21 = metadata !{i32 786445, metadata !1, metadata !"_ZTS1D", metadata !"a", i32 11, i64 0, i64 0, i64 0, i32 4096, metadata !12, null} ; [ DW_TAG_member ] [a] [line 11, size 0, align 0, offset 0] [static] [from int]
    148 !22 = metadata !{i32 786451, metadata !1, metadata !"_ZTS1D", metadata !"Nested", i32 12, i64 8, i64 8, i32 0, i32 0, null, metadata !2, i32 0, null, null, metadata !"_ZTSN1D6NestedE"} ; [ DW_TAG_structure_type ] [Nested] [line 12, size 8, align 8, offset 0] [def] [from ]
    149 !23 = metadata !{i32 786451, metadata !1, metadata !"_ZTS1D", metadata !"Nested2", i32 13, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null, metadata !"_ZTSN1D7Nested2E"} ; [ DW_TAG_structure_type ] [Nested2] [line 13, size 0, align 0, offset 0] [decl] [from ]
    150 !24 = metadata !{i32 786451, metadata !1, metadata !"_ZTS1D", metadata !"virt<bar>", i32 15, i64 64, i64 64, i32 0, i32 0, null, metadata !25, i32 0, null, metadata !28, metadata !"_ZTSN1D4virtI3barEE"} ; [ DW_TAG_structure_type ] [virt<bar>] [line 15, size 64, align 64, offset 0] [def] [from ]
    151 !25 = metadata !{metadata !26}
    152 !26 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN1D4virtI3barEE", metadata !"values", i32 16, i64 64, i64 64, i64 0, i32 0, metadata !27} ; [ DW_TAG_member ] [values] [line 16, size 64, align 64, offset 0] [from ]
    153 !27 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS3bar"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS3bar]
    154 !28 = metadata !{metadata !29}
    155 !29 = metadata !{i32 786479, null, metadata !"T", metadata !"_ZTS3bar", null, i32 0, i32 0} ; [ DW_TAG_template_type_parameter ]
    156 !30 = metadata !{metadata !31, metadata !32}
    157 !31 = metadata !{i32 786478, metadata !1, null, metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 4, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%struct.C*)* @_ZN1C3fooEv, null, metadata !13, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [foo]
    158 !32 = metadata !{i32 786478, metadata !1, metadata !7, metadata !"test", metadata !"test", metadata !"_Z4testv", i32 20, metadata !33, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_Z4testv, null, null, metadata !2, i32 20} ; [ DW_TAG_subprogram ] [line 20] [def] [test]
    159 !33 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !34, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
    160 !34 = metadata !{null}
    161 !35 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
    162 !36 = metadata !{i32 786689, metadata !31, metadata !"this", null, i32 16777216, metadata !37, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0]
    163 !37 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS1C"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1C]
    164 !38 = metadata !{i32 0, i32 0, metadata !31, null}
    165 !39 = metadata !{i32 5, i32 0, metadata !31, null}
    166 !40 = metadata !{i32 786688, metadata !32, metadata !"B", metadata !7, i32 21, metadata !41, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [B] [line 21]
    167 !41 = metadata !{i32 786454, metadata !1, null, metadata !"baz", i32 8, i64 0, i64 0, i64 0, i32 0, metadata !"_ZTS3bar"} ; [ DW_TAG_typedef ] [baz] [line 8, size 0, align 0, offset 0] [from _ZTS3bar]
    168 !42 = metadata !{i32 21, i32 0, metadata !32, null}
    169 !43 = metadata !{i32 786688, metadata !32, metadata !"A", metadata !7, i32 22, metadata !44, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [A] [line 22]
    170 !44 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 24, i64 8, i32 0, i32 0, metadata !"_ZTS3bar", metadata !45, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 24, align 8, offset 0] [from _ZTS3bar]
    171 !45 = metadata !{metadata !46}
    172 !46 = metadata !{i32 786465, i64 0, i64 3}        ; [ DW_TAG_subrange_type ] [0, 2]
    173 !47 = metadata !{i32 22, i32 0, metadata !32, null}
    174 !48 = metadata !{i32 786688, metadata !32, metadata !"B2", metadata !7, i32 23, metadata !49, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [B2] [line 23]
    175 !49 = metadata !{i32 786454, metadata !1, metadata !"_ZTS1D", metadata !"baz2", i32 10, i64 0, i64 0, i64 0, i32 0, metadata !"_ZTS3bar"} ; [ DW_TAG_typedef ] [baz2] [line 10, size 0, align 0, offset 0] [from _ZTS3bar]
    176 !50 = metadata !{i32 23, i32 0, metadata !32, null}
    177 !51 = metadata !{i32 786688, metadata !32, metadata !"e", metadata !7, i32 24, metadata !22, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [e] [line 24]
    178 !52 = metadata !{i32 24, i32 0, metadata !32, null}
    179 !53 = metadata !{i32 786688, metadata !32, metadata !"p", metadata !7, i32 25, metadata !54, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [p] [line 25]
    180 !54 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTSN1D7Nested2E"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTSN1D7Nested2E]
    181 !55 = metadata !{i32 25, i32 0, metadata !32, null}
    182 !56 = metadata !{i32 786688, metadata !32, metadata !"t", metadata !7, i32 26, metadata !24, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [t] [line 26]
    183 !57 = metadata !{i32 26, i32 0, metadata !32, null}
    184 !58 = metadata !{i32 27, i32 0, metadata !32, null}
    185 !59 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
    186