1 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s
2 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s
3 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj -dwarf-version=3 < %s | llvm-dwarfdump - | FileCheck %s -check-prefix=DWARF3
4 ; ModuleID = 'dwarf-public-names.cpp'
9 ; void member_function();
10 ; static int static_member_function();
11 ; static int static_member_variable;
14 ; int C::static_member_variable = 0;
16 ; void C::member_function() {
17 ; static_member_variable = 0;
20 ; int C::static_member_function() {
21 ; return static_member_variable;
26 ; int global_function() {
31 ; void global_namespace_function() {
32 ; global_variable.member_function();
34 ; int global_namespace_variable = 1;
40 ; ASM: .section .debug_gnu_pubnames
41 ; ASM: .byte 32 # Kind: VARIABLE, EXTERNAL
42 ; ASM-NEXT: .asciz "global_variable" # External Name
44 ; ASM: .section .debug_gnu_pubtypes
45 ; ASM: .byte 16 # Kind: TYPE, EXTERNAL
46 ; ASM-NEXT: .asciz "C" # External Name
48 ; CHECK: .debug_info contents:
49 ; CHECK: Compile Unit: length = [[UNIT_SIZE:[0-9a-f]+]]
50 ; CHECK: DW_AT_GNU_pubnames [DW_FORM_sec_offset] (0x00000000)
51 ; CHECK: DW_AT_GNU_pubtypes [DW_FORM_sec_offset] (0x00000000)
53 ; CHECK: [[C:[0-9a-f]+]]: DW_TAG_structure_type
54 ; CHECK-NEXT: DW_AT_name {{.*}} "C"
56 ; CHECK: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member
57 ; CHECK-NEXT: DW_AT_name {{.*}} "static_member_variable"
59 ; CHECK: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
60 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
61 ; CHECK-NEXT: DW_AT_name {{.*}} "member_function"
63 ; CHECK: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
64 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
65 ; CHECK-NEXT: DW_AT_name {{.*}} "static_member_function"
67 ; CHECK: [[INT:[0-9a-f]+]]: DW_TAG_base_type
68 ; CHECK-NEXT: DW_AT_name {{.*}} "int"
70 ; CHECK: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable
71 ; CHECK-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]]
73 ; CHECK: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable
74 ; CHECK-NEXT: DW_AT_name {{.*}} "global_variable"
76 ; CHECK: [[NS:[0-9a-f]+]]: DW_TAG_namespace
77 ; CHECK-NEXT: DW_AT_name {{.*}} "ns"
79 ; CHECK: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
80 ; CHECK-NEXT: DW_AT_name {{.*}} "global_namespace_variable"
82 ; CHECK: [[D_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
83 ; CHECK-NEXT: DW_AT_name {{.*}} "d"
85 ; CHECK: [[D:[0-9a-f]+]]: DW_TAG_structure_type
86 ; CHECK-NEXT: DW_AT_name {{.*}} "D"
88 ; CHECK: [[GLOB_NS_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
89 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
90 ; CHECK-NEXT: DW_AT_name {{.*}} "global_namespace_function"
92 ; CHECK: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable
93 ; CHECK-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]]
95 ; CHECK: [[D_VAR:[0-9a-f]+]]: DW_TAG_variable
96 ; CHECK-NEXT: DW_AT_specification {{.*}}[[D_VAR_DECL]]
98 ; CHECK: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
99 ; CHECK-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]]
101 ; CHECK: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
102 ; CHECK-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]]
104 ; CHECK: [[GLOBAL_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
105 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
106 ; CHECK-NEXT: DW_AT_name {{.*}} "global_function"
108 ; CHECK-LABEL: .debug_gnu_pubnames contents:
109 ; CHECK-NEXT: length = 0x000000e7 version = 0x0002 unit_offset = 0x00000000 unit_size = [[UNIT_SIZE]]
110 ; CHECK-NEXT: Offset Linkage Kind Name
111 ; CHECK-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function"
112 ; CHECK-DAG: [[NS]] EXTERNAL TYPE "ns"
113 ; CHECK-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function"
114 ; CHECK-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable"
115 ; CHECK-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable"
116 ; CHECK-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function"
117 ; CHECK-DAG: [[D_VAR]] EXTERNAL VARIABLE "ns::d"
118 ; CHECK-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable"
119 ; CHECK-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function"
122 ; CHECK-LABEL: debug_gnu_pubtypes contents:
123 ; CHECK: Offset Linkage Kind Name
124 ; CHECK-DAG: [[C]] EXTERNAL TYPE "C"
125 ; CHECK-DAG: [[D]] EXTERNAL TYPE "ns::D"
126 ; CHECK-DAG: [[INT]] STATIC TYPE "int"
128 ; DWARF3: .debug_info contents:
129 ; DWARF3: Compile Unit: length = [[UNIT_SIZE:[0-9a-f]+]]
130 ; DWARF3: DW_AT_GNU_pubnames [DW_FORM_data4] (0x00000000)
131 ; DWARF3: DW_AT_GNU_pubtypes [DW_FORM_data4] (0x00000000)
133 ; DWARF3: [[C:[0-9a-f]+]]: DW_TAG_structure_type
134 ; DWARF3-NEXT: DW_AT_name {{.*}} "C"
136 ; DWARF3: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member
137 ; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_variable"
139 ; DWARF3: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
140 ; DWARF3-NEXT: DW_AT_MIPS_linkage_name
141 ; DWARF3-NEXT: DW_AT_name {{.*}} "member_function"
143 ; DWARF3: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
144 ; DWARF3-NEXT: DW_AT_MIPS_linkage_name
145 ; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_function"
147 ; DWARF3: [[INT:[0-9a-f]+]]: DW_TAG_base_type
148 ; DWARF3-NEXT: DW_AT_name {{.*}} "int"
150 ; DWARF3: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable
151 ; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]]
153 ; DWARF3: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable
154 ; DWARF3-NEXT: DW_AT_name {{.*}} "global_variable"
156 ; DWARF3: [[NS:[0-9a-f]+]]: DW_TAG_namespace
157 ; DWARF3-NEXT: DW_AT_name {{.*}} "ns"
159 ; DWARF3: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
160 ; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_variable"
162 ; DWARF3: [[D_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
163 ; DWARF3-NEXT: DW_AT_name {{.*}} "d"
165 ; DWARF3: [[D:[0-9a-f]+]]: DW_TAG_structure_type
166 ; DWARF3-NEXT: DW_AT_name {{.*}} "D"
168 ; DWARF3: [[GLOB_NS_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
169 ; DWARF3-NEXT: DW_AT_MIPS_linkage_name
170 ; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_function"
172 ; DWARF3: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable
173 ; DWARF3-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]]
175 ; DWARF3: [[D_VAR:[0-9a-f]+]]: DW_TAG_variable
176 ; DWARF3-NEXT: DW_AT_specification {{.*}}[[D_VAR_DECL]]
178 ; DWARF3: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
179 ; DWARF3-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]]
181 ; DWARF3: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
182 ; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]]
184 ; DWARF3: [[GLOBAL_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
185 ; DWARF3-NEXT: DW_AT_MIPS_linkage_name
186 ; DWARF3-NEXT: DW_AT_name {{.*}} "global_function"
188 ; DWARF3-LABEL: .debug_gnu_pubnames contents:
189 ; DWARF3-NEXT: length = 0x000000e7 version = 0x0002 unit_offset = 0x00000000 unit_size = [[UNIT_SIZE]]
190 ; DWARF3-NEXT: Offset Linkage Kind Name
191 ; DWARF3-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function"
192 ; DWARF3-DAG: [[NS]] EXTERNAL TYPE "ns"
193 ; DWARF3-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function"
194 ; DWARF3-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable"
195 ; DWARF3-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable"
196 ; DWARF3-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function"
197 ; DWARF3-DAG: [[D_VAR]] EXTERNAL VARIABLE "ns::d"
198 ; DWARF3-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable"
199 ; DWARF3-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function"
202 ; DWARF3-LABEL: debug_gnu_pubtypes contents:
203 ; DWARF3: Offset Linkage Kind Name
204 ; DWARF3-DAG: [[C]] EXTERNAL TYPE "C"
205 ; DWARF3-DAG: [[D]] EXTERNAL TYPE "ns::D"
206 ; DWARF3-DAG: [[INT]] STATIC TYPE "int"
208 %struct.C = type { i8 }
209 %"struct.ns::D" = type { i32 }
211 @_ZN1C22static_member_variableE = global i32 0, align 4
212 @global_variable = global %struct.C zeroinitializer, align 1
213 @_ZN2ns25global_namespace_variableE = global i32 1, align 4
214 @_ZN2ns1dE = global %"struct.ns::D" zeroinitializer, align 4
216 ; Function Attrs: nounwind uwtable
217 define void @_ZN1C15member_functionEv(%struct.C* %this) #0 align 2 {
219 %this.addr = alloca %struct.C*, align 8
220 store %struct.C* %this, %struct.C** %this.addr, align 8
221 call void @llvm.dbg.declare(metadata !{%struct.C** %this.addr}, metadata !36), !dbg !38
222 %this1 = load %struct.C** %this.addr
223 store i32 0, i32* @_ZN1C22static_member_variableE, align 4, !dbg !39
227 ; Function Attrs: nounwind readnone
228 declare void @llvm.dbg.declare(metadata, metadata) #1
230 ; Function Attrs: nounwind uwtable
231 define i32 @_ZN1C22static_member_functionEv() #0 align 2 {
233 %0 = load i32* @_ZN1C22static_member_variableE, align 4, !dbg !40
237 ; Function Attrs: nounwind uwtable
238 define i32 @_Z15global_functionv() #0 {
243 ; Function Attrs: nounwind uwtable
244 define void @_ZN2ns25global_namespace_functionEv() #0 {
246 call void @_ZN1C15member_functionEv(%struct.C* @global_variable), !dbg !42
250 attributes #0 = { nounwind 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" }
251 attributes #1 = { nounwind readnone }
254 !llvm.module.flags = !{!34, !43}
257 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 (trunk 192862) (llvm/trunk 192861)", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !21, metadata !29, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/echristo/tmp/pubnames.cpp] [DW_LANG_C_plus_plus]
258 !1 = metadata !{metadata !"pubnames.cpp", metadata !"/usr/local/google/home/echristo/tmp"}
259 !2 = metadata !{i32 0}
260 !3 = metadata !{metadata !4, metadata !17}
261 !4 = metadata !{i32 786451, metadata !1, null, metadata !"C", i32 1, i64 8, i64 8, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] [line 1, size 8, align 8, offset 0] [def] [from ]
262 !5 = metadata !{metadata !6, metadata !8, metadata !13}
263 !6 = metadata !{i32 786445, metadata !1, metadata !"_ZTS1C", metadata !"static_member_variable", i32 4, i64 0, i64 0, i64 0, i32 4096, metadata !7, null} ; [ DW_TAG_member ] [static_member_variable] [line 4, size 0, align 0, offset 0] [static] [from int]
264 !7 = 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]
265 !8 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"member_function", metadata !"member_function", metadata !"_ZN1C15member_functionEv", i32 2, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !12, i32 2} ; [ DW_TAG_subprogram ] [line 2] [member_function]
266 !9 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
267 !10 = metadata !{null, metadata !11}
268 !11 = 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]
269 !12 = metadata !{i32 786468}
270 !13 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"static_member_function", metadata !"static_member_function", metadata !"_ZN1C22static_member_functionEv", i32 3, metadata !14, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !16, i32 3} ; [ DW_TAG_subprogram ] [line 3] [static_member_function]
271 !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 ]
272 !15 = metadata !{metadata !7}
273 !16 = metadata !{i32 786468}
274 !17 = metadata !{i32 786451, metadata !1, metadata !18, metadata !"D", i32 21, i64 32, i64 32, i32 0, i32 0, null, metadata !19, i32 0, null, null, metadata !"_ZTSN2ns1DE"} ; [ DW_TAG_structure_type ] [D] [line 21, size 32, align 32, offset 0] [def] [from ]
275 !18 = metadata !{i32 786489, metadata !1, null, metadata !"ns", i32 17} ; [ DW_TAG_namespace ] [ns] [line 17]
276 !19 = metadata !{metadata !20}
277 !20 = metadata !{i32 786445, metadata !1, metadata !"_ZTSN2ns1DE", metadata !"A", i32 22, i64 32, i64 32, i64 0, i32 0, metadata !7} ; [ DW_TAG_member ] [A] [line 22, size 32, align 32, offset 0] [from int]
278 !21 = metadata !{metadata !22, metadata !23, metadata !24, metadata !26}
279 !22 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"member_function", metadata !"member_function", metadata !"_ZN1C15member_functionEv", i32 9, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%struct.C*)* @_ZN1C15member_functionEv, null, metadata !8, metadata !2, i32 9} ; [ DW_TAG_subprogram ] [line 9] [def] [member_function]
280 !23 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"static_member_function", metadata !"static_member_function", metadata !"_ZN1C22static_member_functionEv", i32 11, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_ZN1C22static_member_functionEv, null, metadata !13, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 11] [def] [static_member_function]
281 !24 = metadata !{i32 786478, metadata !1, metadata !25, metadata !"global_function", metadata !"global_function", metadata !"_Z15global_functionv", i32 15, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z15global_functionv, null, null, metadata !2, i32 15} ; [ DW_TAG_subprogram ] [line 15] [def] [global_function]
282 !25 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/usr/local/google/home/echristo/tmp/pubnames.cpp]
283 !26 = metadata !{i32 786478, metadata !1, metadata !18, metadata !"global_namespace_function", metadata !"global_namespace_function", metadata !"_ZN2ns25global_namespace_functionEv", i32 18, metadata !27, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_ZN2ns25global_namespace_functionEv, null, null, metadata !2, i32 18} ; [ DW_TAG_subprogram ] [line 18] [def] [global_namespace_function]
284 !27 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !28, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
285 !28 = metadata !{null}
286 !29 = metadata !{metadata !30, metadata !31, metadata !32, metadata !33}
287 !30 = metadata !{i32 786484, i32 0, metadata !4, metadata !"static_member_variable", metadata !"static_member_variable", metadata !"_ZN1C22static_member_variableE", metadata !25, i32 7, metadata !7, i32 0, i32 1, i32* @_ZN1C22static_member_variableE, metadata !6} ; [ DW_TAG_variable ] [static_member_variable] [line 7] [def]
288 !31 = metadata !{i32 786484, i32 0, null, metadata !"global_variable", metadata !"global_variable", metadata !"", metadata !25, i32 13, metadata !4, i32 0, i32 1, %struct.C* @global_variable, null} ; [ DW_TAG_variable ] [global_variable] [line 13] [def]
289 !32 = metadata !{i32 786484, i32 0, metadata !18, metadata !"global_namespace_variable", metadata !"global_namespace_variable", metadata !"_ZN2ns25global_namespace_variableE", metadata !25, i32 19, metadata !7, i32 0, i32 1, i32* @_ZN2ns25global_namespace_variableE, null} ; [ DW_TAG_variable ] [global_namespace_variable] [line 19] [def]
290 !33 = metadata !{i32 786484, i32 0, metadata !18, metadata !"d", metadata !"d", metadata !"_ZN2ns1dE", metadata !25, i32 23, metadata !17, i32 0, i32 1, %"struct.ns::D"* @_ZN2ns1dE, null} ; [ DW_TAG_variable ] [d] [line 23] [def]
291 !34 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
292 !35 = metadata !{metadata !"clang version 3.4 (trunk 192862) (llvm/trunk 192861)"}
293 !36 = metadata !{i32 786689, metadata !22, metadata !"this", null, i32 16777216, metadata !37, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0]
294 !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]
295 !38 = metadata !{i32 0, i32 0, metadata !22, null}
296 !39 = metadata !{i32 9, i32 0, metadata !22, null}
297 !40 = metadata !{i32 11, i32 0, metadata !23, null}
298 !41 = metadata !{i32 15, i32 0, metadata !24, null}
299 !42 = metadata !{i32 18, i32 0, metadata !26, null}
301 !43 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}