blob: 01aa79b2fc9c92521c986176fbcb075471528d52 [file] [log] [blame]
Eric Christopher7da24882013-08-19 21:07:38 +00001; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t.o < %s
Adrian Prantl7bc1b282017-09-11 22:59:45 +00002; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck --check-prefix=LINUX %s
Eric Christopher7da24882013-08-19 21:07:38 +00003; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj -o %t.o < %s
Adrian Prantl7bc1b282017-09-11 22:59:45 +00004; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck --check-prefix=NOPUB %s
Paul Robinson49e38962015-03-05 00:08:27 +00005; RUN: llc -mtriple=x86_64-scei-ps4 -filetype=obj -o %t.o < %s
Adrian Prantl7bc1b282017-09-11 22:59:45 +00006; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck --check-prefix=NOPUB %s
Eric Christopher7da24882013-08-19 21:07:38 +00007; ModuleID = 'dwarf-public-names.cpp'
8;
9; Generated from:
10;
11; struct C {
12; void member_function();
13; static int static_member_function();
14; static int static_member_variable;
15; };
16;
17; int C::static_member_variable = 0;
18;
19; void C::member_function() {
20; static_member_variable = 0;
21; }
22;
23; int C::static_member_function() {
24; return static_member_variable;
25; }
26;
27; C global_variable;
28;
29; int global_function() {
30; return -1;
31; }
32;
33; namespace ns {
34; void global_namespace_function() {
35; global_variable.member_function();
36; }
37; int global_namespace_variable = 1;
38; }
39
Paul Robinson49e38962015-03-05 00:08:27 +000040; Darwin and PS4 shouldn't be generating the section by default
41; NOPUB: debug_pubnames
Paul Robinsone6c34b42015-06-25 19:37:13 +000042; NOPUB-NEXT: {{^$}}
Eric Christopher7da24882013-08-19 21:07:38 +000043
44; Skip the output to the header of the pubnames section.
45; LINUX: debug_pubnames
Adrian Prantlfed4f392017-04-28 22:25:46 +000046; LINUX-NEXT: unit_size = 0x00000128
Eric Christopher7da24882013-08-19 21:07:38 +000047
48; Check for each name in the output.
David Blaikie553eb4a2014-06-06 22:16:56 +000049; LINUX-DAG: "ns"
David Blaikie3dca5992014-06-06 22:29:05 +000050; LINUX-DAG: "C::static_member_function"
David Blaikie553eb4a2014-06-06 22:16:56 +000051; LINUX-DAG: "global_variable"
52; LINUX-DAG: "ns::global_namespace_variable"
53; LINUX-DAG: "ns::global_namespace_function"
54; LINUX-DAG: "global_function"
55; LINUX-DAG: "C::static_member_variable"
David Blaikie3dca5992014-06-06 22:29:05 +000056; LINUX-DAG: "C::member_function"
Eric Christopher7da24882013-08-19 21:07:38 +000057
Adrian Prantl1eadba12016-12-22 00:45:21 +000058source_filename = "test/DebugInfo/X86/dwarf-public-names.ll"
59
Eric Christopher7da24882013-08-19 21:07:38 +000060%struct.C = type { i8 }
61
Adrian Prantl1eadba12016-12-22 00:45:21 +000062@_ZN1C22static_member_variableE = global i32 0, align 4, !dbg !0
63@global_variable = global %struct.C zeroinitializer, align 1, !dbg !15
64@_ZN2ns25global_namespace_variableE = global i32 1, align 4, !dbg !17
Eric Christopher7da24882013-08-19 21:07:38 +000065
Adrian Prantl1eadba12016-12-22 00:45:21 +000066; Function Attrs: nounwind uwtable
67define void @_ZN1C15member_functionEv(%struct.C* %this) #0 align 2 !dbg !23 {
Eric Christopher7da24882013-08-19 21:07:38 +000068entry:
69 %this.addr = alloca %struct.C*, align 8
70 store %struct.C* %this, %struct.C** %this.addr, align 8
Adrian Prantl1eadba12016-12-22 00:45:21 +000071 call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !24, metadata !26), !dbg !27
David Blaikiea79ac142015-02-27 21:17:42 +000072 %this1 = load %struct.C*, %struct.C** %this.addr
Adrian Prantl1eadba12016-12-22 00:45:21 +000073 store i32 0, i32* @_ZN1C22static_member_variableE, align 4, !dbg !28
74 ret void, !dbg !29
Eric Christopher7da24882013-08-19 21:07:38 +000075}
76
Adrian Prantl1eadba12016-12-22 00:45:21 +000077; Function Attrs: nounwind readnone
78declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Eric Christopher7da24882013-08-19 21:07:38 +000079
Adrian Prantl1eadba12016-12-22 00:45:21 +000080; Function Attrs: nounwind uwtable
81define i32 @_ZN1C22static_member_functionEv() #0 align 2 !dbg !30 {
Eric Christopher7da24882013-08-19 21:07:38 +000082entry:
Adrian Prantl1eadba12016-12-22 00:45:21 +000083 %0 = load i32, i32* @_ZN1C22static_member_variableE, align 4, !dbg !31
84 ret i32 %0, !dbg !31
Eric Christopher7da24882013-08-19 21:07:38 +000085}
86
Adrian Prantl1eadba12016-12-22 00:45:21 +000087; Function Attrs: nounwind uwtable
88define i32 @_Z15global_functionv() #0 !dbg !32 {
Eric Christopher7da24882013-08-19 21:07:38 +000089entry:
Adrian Prantl1eadba12016-12-22 00:45:21 +000090 ret i32 -1, !dbg !33
Eric Christopher7da24882013-08-19 21:07:38 +000091}
92
Adrian Prantl1eadba12016-12-22 00:45:21 +000093; Function Attrs: nounwind uwtable
94define void @_ZN2ns25global_namespace_functionEv() #0 !dbg !34 {
Eric Christopher7da24882013-08-19 21:07:38 +000095entry:
Adrian Prantl1eadba12016-12-22 00:45:21 +000096 call void @_ZN1C15member_functionEv(%struct.C* @global_variable), !dbg !37
97 ret void, !dbg !38
Eric Christopher7da24882013-08-19 21:07:38 +000098}
99
100attributes #0 = { nounwind uwtable }
101attributes #1 = { nounwind readnone }
102
Adrian Prantl1eadba12016-12-22 00:45:21 +0000103!llvm.dbg.cu = !{!20}
104!llvm.module.flags = !{!22}
Eric Christopher7da24882013-08-19 21:07:38 +0000105
Adrian Prantl05782212017-08-30 18:06:51 +0000106!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +0000107!1 = !DIGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true, declaration: !5)
108!2 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !3, line: 1, size: 8, elements: !4)
109!3 = !DIFile(filename: "dwarf-public-names.cpp", directory: "/usr2/kparzysz/s.hex/t")
110!4 = !{!5, !7, !12}
111!5 = !DIDerivedType(tag: DW_TAG_member, name: "static_member_variable", scope: !2, file: !3, line: 4, baseType: !6, flags: DIFlagStaticMember)
112!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
113!7 = !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: false, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, variables: !11)
114!8 = !DISubroutineType(types: !9)
115!9 = !{null, !10}
116!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
117!11 = !{}
118!12 = !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: !2, file: !3, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, variables: !11)
119!13 = !DISubroutineType(types: !14)
120!14 = !{!6}
Adrian Prantl05782212017-08-30 18:06:51 +0000121!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +0000122!16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type
Adrian Prantl05782212017-08-30 18:06:51 +0000123!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +0000124!18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true)
Adrian Prantlfed4f392017-04-28 22:25:46 +0000125!19 = !DINamespace(name: "ns", scope: null)
Adrian Prantl1eadba12016-12-22 00:45:21 +0000126!20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.3 (http://llvm.org/git/clang.git a09cd8103a6a719cb2628cdf0c91682250a17bd2) (http://llvm.org/git/llvm.git 47d03cec0afca0c01ae42b82916d1d731716cd20)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !21, imports: !11) ; previously: invalid DW_TAG_base_type
127!21 = !{!0, !15, !17}
128!22 = !{i32 1, !"Debug Info Version", i32 3}
129!23 = distinct !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: null, file: !3, line: 9, type: !8, isLocal: false, isDefinition: true, scopeLine: 9, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !7, variables: !11)
130!24 = !DILocalVariable(name: "this", arg: 1, scope: !23, file: !3, line: 9, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer)
131!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64)
132!26 = !DIExpression()
133!27 = !DILocation(line: 9, scope: !23)
134!28 = !DILocation(line: 10, scope: !23)
135!29 = !DILocation(line: 11, scope: !23)
136!30 = distinct !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: null, file: !3, line: 13, type: !13, isLocal: false, isDefinition: true, scopeLine: 13, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !12, variables: !11)
137!31 = !DILocation(line: 14, scope: !30)
138!32 = distinct !DISubprogram(name: "global_function", linkageName: "_Z15global_functionv", scope: !3, file: !3, line: 19, type: !13, isLocal: false, isDefinition: true, scopeLine: 19, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, variables: !11)
139!33 = !DILocation(line: 20, scope: !32)
140!34 = distinct !DISubprogram(name: "global_namespace_function", linkageName: "_ZN2ns25global_namespace_functionEv", scope: !19, file: !3, line: 24, type: !35, isLocal: false, isDefinition: true, scopeLine: 24, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, variables: !11)
141!35 = !DISubroutineType(types: !36)
142!36 = !{null}
143!37 = !DILocation(line: 25, scope: !34)
144!38 = !DILocation(line: 26, scope: !34)
145