2d9b4691783f3c2e52768c46f5edf3708745c560
[oota-llvm.git] / test / DebugInfo / X86 / dwarf-public-names.ll
1 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t.o < %s
2 ; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck --check-prefix=LINUX %s
3 ; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj -o %t.o < %s
4 ; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck --check-prefix=DARWIN %s
5 ; ModuleID = 'dwarf-public-names.cpp'
6 ;
7 ; Generated from:
8 ;
9 ; struct C {
10 ;   void member_function();
11 ;   static int static_member_function();
12 ;   static int static_member_variable;
13 ; };
14 ;
15 ; int C::static_member_variable = 0;
16 ;
17 ; void C::member_function() {
18 ;   static_member_variable = 0;
19 ; }
20 ;
21 ; int C::static_member_function() {
22 ;   return static_member_variable;
23 ; }
24 ;
25 ; C global_variable;
26 ;
27 ; int global_function() {
28 ;   return -1;
29 ; }
30 ;
31 ; namespace ns {
32 ;   void global_namespace_function() {
33 ;     global_variable.member_function();
34 ;   }
35 ;   int global_namespace_variable = 1;
36 ; }
37
38 ; Darwin shouldn't be generating the section by default
39 ; DARWIN: debug_pubnames
40 ; DARWIN: {{^$}}
41
42 ; Skip the output to the header of the pubnames section.
43 ; LINUX: debug_pubnames
44 ; LINUX: unit_size = 0x00000128
45
46 ; Check for each name in the output.
47 ; LINUX-DAG: "ns"
48 ; LINUX-DAG: "C::static_member_function"
49 ; LINUX-DAG: "global_variable"
50 ; LINUX-DAG: "ns::global_namespace_variable"
51 ; LINUX-DAG: "ns::global_namespace_function"
52 ; LINUX-DAG: "global_function"
53 ; LINUX-DAG: "C::static_member_variable"
54 ; LINUX-DAG: "C::member_function"
55
56 %struct.C = type { i8 }
57
58 @_ZN1C22static_member_variableE = global i32 0, align 4
59 @global_variable = global %struct.C zeroinitializer, align 1
60 @_ZN2ns25global_namespace_variableE = global i32 1, align 4
61
62 define void @_ZN1C15member_functionEv(%struct.C* %this) nounwind uwtable align 2 {
63 entry:
64   %this.addr = alloca %struct.C*, align 8
65   store %struct.C* %this, %struct.C** %this.addr, align 8
66   call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !28, metadata !MDExpression()), !dbg !30
67   %this1 = load %struct.C*, %struct.C** %this.addr
68   store i32 0, i32* @_ZN1C22static_member_variableE, align 4, !dbg !31
69   ret void, !dbg !32
70 }
71
72 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
73
74 define i32 @_ZN1C22static_member_functionEv() nounwind uwtable align 2 {
75 entry:
76   %0 = load i32, i32* @_ZN1C22static_member_variableE, align 4, !dbg !33
77   ret i32 %0, !dbg !33
78 }
79
80 define i32 @_Z15global_functionv() nounwind uwtable {
81 entry:
82   ret i32 -1, !dbg !34
83 }
84
85 define void @_ZN2ns25global_namespace_functionEv() nounwind uwtable {
86 entry:
87   call void @_ZN1C15member_functionEv(%struct.C* @global_variable), !dbg !35
88   ret void, !dbg !36
89 }
90
91 attributes #0 = { nounwind uwtable }
92 attributes #1 = { nounwind readnone }
93
94 !llvm.dbg.cu = !{!0}
95 !llvm.module.flags = !{!38}
96
97 !0 = !MDCompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (http://llvm.org/git/clang.git a09cd8103a6a719cb2628cdf0c91682250a17bd2) (http://llvm.org/git/llvm.git 47d03cec0afca0c01ae42b82916d1d731716cd20)", isOptimized: false, emissionKind: 0, file: !37, enums: !1, retainedTypes: !1, subprograms: !2, globals: !24, imports:  !1)
98 !1 = !{}
99 !2 = !{!3, !18, !19, !20}
100 !3 = !MDSubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", line: 9, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 9, file: !4, scope: null, type: !5, function: void (%struct.C*)* @_ZN1C15member_functionEv, declaration: !12, variables: !1)
101 !4 = !MDFile(filename: "dwarf-public-names.cpp", directory: "/usr2/kparzysz/s.hex/t")
102 !5 = !MDSubroutineType(types: !6)
103 !6 = !{null, !7}
104 !7 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !8)
105 !8 = !MDCompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, size: 8, align: 8, file: !37, elements: !9)
106 !9 = !{!10, !12, !14}
107 !10 = !MDDerivedType(tag: DW_TAG_member, name: "static_member_variable", line: 4, flags: DIFlagStaticMember, file: !37, scope: !8, baseType: !11)
108 !11 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
109 !12 = !MDSubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", line: 2, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !4, scope: !8, type: !5, variables: !13)
110 !13 = !{} ; previously: invalid DW_TAG_base_type
111 !14 = !MDSubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !4, scope: !8, type: !15, variables: !17)
112 !15 = !MDSubroutineType(types: !16)
113 !16 = !{!11}
114 !17 = !{} ; previously: invalid DW_TAG_base_type
115 !18 = !MDSubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 13, file: !4, scope: null, type: !15, function: i32 ()* @_ZN1C22static_member_functionEv, declaration: !14, variables: !1)
116 !19 = !MDSubprogram(name: "global_function", linkageName: "_Z15global_functionv", line: 19, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 19, file: !4, scope: !4, type: !15, function: i32 ()* @_Z15global_functionv, variables: !1)
117 !20 = !MDSubprogram(name: "global_namespace_function", linkageName: "_ZN2ns25global_namespace_functionEv", line: 24, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 24, file: !4, scope: !21, type: !22, function: void ()* @_ZN2ns25global_namespace_functionEv, variables: !1)
118 !21 = !MDNamespace(name: "ns", line: 23, file: !4, scope: null)
119 !22 = !MDSubroutineType(types: !23)
120 !23 = !{null}
121 !24 = !{!25, !26, !27}
122 !25 = !MDGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", line: 7, isLocal: false, isDefinition: true, scope: !8, file: !4, type: !11, variable: i32* @_ZN1C22static_member_variableE, declaration: !10)
123 !26 = !MDGlobalVariable(name: "global_variable", line: 17, isLocal: false, isDefinition: true, scope: null, file: !4, type: !8, variable: %struct.C* @global_variable)
124 !27 = !MDGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", line: 27, isLocal: false, isDefinition: true, scope: !21, file: !4, type: !11, variable: i32* @_ZN2ns25global_namespace_variableE)
125 !28 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "this", line: 9, arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !3, file: !4, type: !29)
126 !29 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !8)
127 !30 = !MDLocation(line: 9, scope: !3)
128 !31 = !MDLocation(line: 10, scope: !3)
129 !32 = !MDLocation(line: 11, scope: !3)
130 !33 = !MDLocation(line: 14, scope: !18)
131 !34 = !MDLocation(line: 20, scope: !19)
132 !35 = !MDLocation(line: 25, scope: !20)
133 !36 = !MDLocation(line: 26, scope: !20)
134 !37 = !MDFile(filename: "dwarf-public-names.cpp", directory: "/usr2/kparzysz/s.hex/t")
135 !38 = !{i32 1, !"Debug Info Version", i32 3}