Home | History | Annotate | Download | only in X86
      1 ; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu -dwarf-version=4
      2 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=PRESENT 
      3 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=ABSENT
      4 ; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-apple-darwin -dwarf-version=4
      5 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINP
      6 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINA
      7 ; Verify that attributes we do want are PRESENT;
      8 ; verify that attributes we don't want are ABSENT.
      9 ; It's a lot easier to do this in two passes than in one.
     10 ; PR14471
     11 
     12 ; LLVM IR generated using: clang -emit-llvm -S -g
     13 ; (with the Clang part of this patch applied).
     14 ;
     15 ; class C
     16 ; {
     17 ;   static int a;
     18 ;   const static bool const_a = true;
     19 ; protected:
     20 ;   static int b;
     21 ;   const static float const_b = 3.14;
     22 ; public:
     23 ;   static int c;
     24 ;   const static int const_c = 18;
     25 ;   int d;
     26 ; };
     27 ; 
     28 ; int C::a = 4;
     29 ; int C::b = 2;
     30 ; int C::c = 1;
     31 ; 
     32 ; int main()
     33 ; {
     34 ;         C instance_C;
     35 ;         instance_C.d = 8;
     36 ;         return C::c;
     37 ; }
     38 
     39 source_filename = "test/DebugInfo/X86/debug-info-static-member.ll"
     40 
     41 %class.C = type { i32 }
     42 
     43 @_ZN1C1aE = global i32 4, align 4, !dbg !0
     44 @_ZN1C1bE = global i32 2, align 4, !dbg !18
     45 @_ZN1C1cE = global i32 1, align 4, !dbg !20
     46 
     47 ; Function Attrs: nounwind uwtable
     48 define i32 @main() #0 !dbg !26 {
     49 entry:
     50   %retval = alloca i32, align 4
     51   %instance_C = alloca %class.C, align 4
     52   store i32 0, i32* %retval
     53   call void @llvm.dbg.declare(metadata %class.C* %instance_C, metadata !29, metadata !30), !dbg !31
     54   %d = getelementptr inbounds %class.C, %class.C* %instance_C, i32 0, i32 0, !dbg !32
     55   store i32 8, i32* %d, align 4, !dbg !32
     56   %0 = load i32, i32* @_ZN1C1cE, align 4, !dbg !33
     57   ret i32 %0, !dbg !33
     58 }
     59 
     60 ; Function Attrs: nounwind readnone
     61 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     62 
     63 attributes #0 = { nounwind uwtable }
     64 attributes #1 = { nounwind readnone }
     65 
     66 !llvm.dbg.cu = !{!22}
     67 !llvm.module.flags = !{!25}
     68 
     69 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
     70 !1 = !DIGlobalVariable(name: "a", linkageName: "_ZN1C1aE", scope: null, file: !2, line: 14, type: !3, isLocal: false, isDefinition: true, declaration: !4)
     71 !2 = !DIFile(filename: "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp", directory: "/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm")
     72 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     73 !4 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !5, file: !2, line: 3, baseType: !3, flags: DIFlagPrivate | DIFlagStaticMember)
     74 !5 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 1, size: 32, align: 32, elements: !6)
     75 !6 = !{!4, !7, !10, !11, !14, !15, !17}
     76 !7 = !DIDerivedType(tag: DW_TAG_member, name: "const_a", scope: !5, file: !2, line: 4, baseType: !8, flags: DIFlagPrivate | DIFlagStaticMember, extraData: i1 true)
     77 !8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
     78 !9 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
     79 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !2, line: 6, baseType: !3, flags: DIFlagProtected | DIFlagStaticMember)
     80 !11 = !DIDerivedType(tag: DW_TAG_member, name: "const_b", scope: !5, file: !2, line: 7, baseType: !12, flags: DIFlagProtected | DIFlagStaticMember, extraData: float 0x40091EB860000000)
     81 !12 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !13)
     82 !13 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
     83 !14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !2, line: 9, baseType: !3, flags: DIFlagPublic | DIFlagStaticMember)
     84 !15 = !DIDerivedType(tag: DW_TAG_member, name: "const_c", scope: !5, file: !2, line: 10, baseType: !16, flags: DIFlagPublic | DIFlagStaticMember, extraData: i32 18)
     85 !16 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !3)
     86 !17 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !5, file: !2, line: 11, baseType: !3, size: 32, align: 32, flags: DIFlagPublic)
     87 !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
     88 !19 = !DIGlobalVariable(name: "b", linkageName: "_ZN1C1bE", scope: null, file: !2, line: 15, type: !3, isLocal: false, isDefinition: true, declaration: !10)
     89 !20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression())
     90 !21 = !DIGlobalVariable(name: "c", linkageName: "_ZN1C1cE", scope: null, file: !2, line: 16, type: !3, isLocal: false, isDefinition: true, declaration: !14)
     91 !22 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.3 (trunk 171914)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !23, retainedTypes: !23, globals: !24, imports: !23)
     92 !23 = !{}
     93 !24 = !{!0, !18, !20}
     94 !25 = !{i32 1, !"Debug Info Version", i32 3}
     95 !26 = distinct !DISubprogram(name: "main", scope: !2, file: !2, line: 18, type: !27, isLocal: false, isDefinition: true, scopeLine: 23, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !22, retainedNodes: !23)
     96 !27 = !DISubroutineType(types: !28)
     97 !28 = !{!3}
     98 !29 = !DILocalVariable(name: "instance_C", scope: !26, file: !2, line: 20, type: !5)
     99 !30 = !DIExpression()
    100 !31 = !DILocation(line: 20, scope: !26)
    101 !32 = !DILocation(line: 21, scope: !26)
    102 !33 = !DILocation(line: 22, scope: !26)
    103 
    104 ; PRESENT verifies that static member declarations have these attributes:
    105 ; external, declaration, accessibility, and either DW_AT_linkage_name
    106 ; (for variables) or DW_AT_const_value (for constants).
    107 ;
    108 ; PRESENT:      .debug_info contents:
    109 ; PRESENT:      DW_TAG_variable
    110 ; PRESENT-NEXT: DW_AT_specification {{.*}} "a"
    111 ; PRESENT-NEXT: DW_AT_location
    112 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
    113 ; PRESENT:      DW_TAG_class_type
    114 ; PRESENT-NEXT: DW_AT_name {{.*}} "C"
    115 ; PRESENT:      DW_TAG_member
    116 ; PRESENT-NEXT: DW_AT_name {{.*}} "a"
    117 ; PRESENT:      DW_AT_external
    118 ; PRESENT:      DW_AT_declaration
    119 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_private)
    120 ; PRESENT:      DW_TAG_member
    121 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_a"
    122 ; PRESENT:      DW_AT_external
    123 ; PRESENT:      DW_AT_declaration
    124 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_private)
    125 ; PRESENT:      DW_AT_const_value {{.*}} (1)
    126 ; PRESENT:      DW_TAG_member
    127 ; PRESENT-NEXT: DW_AT_name {{.*}} "b"
    128 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_protected)
    129 ; PRESENT:      DW_TAG_member
    130 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_b"
    131 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_protected)
    132 ; PRESENT:      DW_AT_const_value [DW_FORM_udata] (1078523331)
    133 ; PRESENT:      DW_TAG_member
    134 ; PRESENT-NEXT: DW_AT_name {{.*}} "c"
    135 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    136 ; PRESENT:      DW_TAG_member
    137 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_c"
    138 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    139 ; PRESENT:      DW_AT_const_value {{.*}} (18)
    140 ; While we're here, a normal member has data_member_location and
    141 ; accessibility attributes.
    142 ; PRESENT:      DW_TAG_member
    143 ; PRESENT-NEXT: DW_AT_name {{.*}} "d"
    144 ; PRESENT:      DW_AT_data_member_location
    145 ; PRESENT:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    146 ; PRESENT:      NULL
    147 ; Definitions point back to their declarations, and have a location.
    148 ; PRESENT:      DW_TAG_variable
    149 ; PRESENT-NEXT: DW_AT_specification {{.*}} "b"
    150 ; PRESENT-NEXT: DW_AT_location
    151 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
    152 ; PRESENT:      DW_TAG_variable
    153 ; PRESENT-NEXT: DW_AT_specification {{.*}} "c"
    154 ; PRESENT-NEXT: DW_AT_location
    155 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
    156 
    157 ; For Darwin gdb:
    158 ; DARWINP:      .debug_info contents:
    159 ; DARWINP:      DW_TAG_variable
    160 ; DARWINP-NEXT: DW_AT_specification {{.*}} "a"
    161 ; DARWINP-NEXT: DW_AT_location
    162 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
    163 ; DARWINP:      DW_TAG_class_type
    164 ; DARWINP-NEXT: DW_AT_name {{.*}} "C"
    165 ; DARWINP:      DW_TAG_member
    166 ; DARWINP-NEXT: DW_AT_name {{.*}} "a"
    167 ; DARWINP:      DW_AT_external
    168 ; DARWINP:      DW_AT_declaration
    169 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_private)
    170 ; DARWINP:      DW_TAG_member
    171 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_a"
    172 ; DARWINP:      DW_AT_external
    173 ; DARWINP:      DW_AT_declaration
    174 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_private)
    175 ; DARWINP:      DW_AT_const_value {{.*}} (1)
    176 ; DARWINP:      DW_TAG_member
    177 ; DARWINP-NEXT: DW_AT_name {{.*}} "b"
    178 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_protected)
    179 ; DARWINP:      DW_TAG_member
    180 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_b"
    181 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_protected)
    182 ; DARWINP:      DW_AT_const_value [DW_FORM_udata] (1078523331)
    183 ; DARWINP:      DW_TAG_member
    184 ; DARWINP-NEXT: DW_AT_name {{.*}} "c"
    185 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    186 ; DARWINP:      DW_TAG_member
    187 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_c"
    188 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    189 ; DARWINP:      DW_AT_const_value {{.*}} (18)
    190 ; While we're here, a normal member has data_member_location and
    191 ; accessibility attributes.
    192 ; DARWINP:      DW_TAG_member
    193 ; DARWINP-NEXT: DW_AT_name {{.*}} "d"
    194 ; DARWINP:      DW_AT_data_member_location
    195 ; DARWINP:      DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
    196 ; DARWINP:      NULL
    197 ; Definitions point back to their declarations, and have a location.
    198 ; DARWINP:      DW_TAG_variable
    199 ; DARWINP-NEXT: DW_AT_specification {{.*}} "b"
    200 ; DARWINP-NEXT: DW_AT_location
    201 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
    202 ; DARWINP:      DW_TAG_variable
    203 ; DARWINP-NEXT: DW_AT_specification {{.*}} "c"
    204 ; DARWINP-NEXT: DW_AT_location
    205 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
    206 
    207 ; ABSENT verifies that static member declarations do not have either
    208 ; DW_AT_location or DW_AT_data_member_location; also, variables do not
    209 ; have DW_AT_const_value and constants do not have DW_AT_linkage_name.
    210 ;
    211 ; ABSENT:      .debug_info contents:
    212 ; ABSENT:      DW_TAG_member
    213 ; ABSENT:      DW_AT_name {{.*}} "a"
    214 ; ABSENT-NOT:  DW_AT_const_value
    215 ; ABSENT-NOT:  location
    216 ; ABSENT:      DW_AT_name {{.*}} "const_a"
    217 ; ABSENT-NOT:  DW_AT_linkage_name
    218 ; ABSENT-NOT:  location
    219 ; ABSENT:      DW_AT_name {{.*}} "b"
    220 ; ABSENT-NOT:  DW_AT_const_value
    221 ; ABSENT-NOT:  location
    222 ; ABSENT:      DW_AT_name {{.*}} "const_b"
    223 ; ABSENT-NOT:  DW_AT_linkage_name
    224 ; ABSENT-NOT:  location
    225 ; ABSENT:      DW_AT_name {{.*}} "c"
    226 ; ABSENT-NOT:  DW_AT_const_value
    227 ; ABSENT-NOT:  location
    228 ; ABSENT:      DW_AT_name {{.*}} "const_c"
    229 ; ABSENT-NOT:  DW_AT_linkage_name
    230 ; ABSENT-NOT:  location
    231 ; While we're here, a normal member does not have a linkage name, constant
    232 ; value, or DW_AT_location.
    233 ; ABSENT:      DW_AT_name {{.*}} "d"
    234 ; ABSENT-NOT:  DW_AT_linkage_name
    235 ; ABSENT-NOT:  DW_AT_const_value
    236 ; ABSENT-NOT:  DW_AT_location
    237 ; ABSENT:      NULL
    238 
    239 ; For Darwin gdb:
    240 ; DARWINA:      .debug_info contents:
    241 ; DARWINA:      DW_TAG_member
    242 ; DARWINA:      DW_AT_name {{.*}} "a"
    243 ; DARWINA-NOT:  DW_AT_const_value
    244 ; DARWINA-NOT:  location
    245 ; DARWINA:      DW_AT_name {{.*}} "const_a"
    246 ; DARWINA-NOT:  DW_AT_linkage_name
    247 ; DARWINA-NOT:  location
    248 ; DARWINA:      DW_AT_name {{.*}} "b"
    249 ; DARWINA-NOT:  DW_AT_const_value
    250 ; DARWINA-NOT:  location
    251 ; DARWINA:      DW_AT_name {{.*}} "const_b"
    252 ; DARWINA-NOT:  DW_AT_linkage_name
    253 ; DARWINA-NOT:  location
    254 ; DARWINA:      DW_AT_name {{.*}} "c"
    255 ; DARWINA-NOT:  DW_AT_const_value
    256 ; DARWINA-NOT:  location
    257 ; DARWINA:      DW_AT_name {{.*}} "const_c"
    258 ; DARWINA-NOT:  DW_AT_linkage_name
    259 ; DARWINA-NOT:  location
    260 ; While we're here, a normal member does not have a linkage name, constant
    261 ; value, or DW_AT_location.
    262 ; DARWINA:      DW_AT_name {{.*}} "d"
    263 ; DARWINA-NOT:  DW_AT_linkage_name
    264 ; DARWINA-NOT:  DW_AT_const_value
    265 ; DARWINA-NOT:  DW_AT_location
    266 ; DARWINA:      NULL
    267