• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; REQUIRES: object-emission
2
3; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
4
5; IR generated with `clang++ -g -emit-llvm -S` from the following code:
6; template<int x, int*, template<typename> class y, decltype(nullptr) n, int ...z>  int func() { return 3; }
7; template<typename> struct y_impl { struct nested { }; };
8; int glbl = func<3, &glbl, y_impl, nullptr, 1, 2>();
9; y_impl<int>::nested n;
10
11; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type
12; CHECK-NEXT: DW_AT_name{{.*}} = "int"
13
14; CHECK: DW_TAG_structure_type
15; CHECK-NEXT: DW_AT_name{{.*}}"y_impl<int>"
16; CHECK-NOT: NULL
17; CHECK: DW_TAG_template_type_parameter
18
19; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, nullptr, 1, 2>"
20; CHECK-NOT: NULL
21; CHECK: DW_TAG_template_value_parameter
22; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
23; CHECK-NEXT: DW_AT_name{{.*}}= "x"
24; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(3)
25
26; CHECK: DW_TAG_template_value_parameter
27; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]}
28
29; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use
30; the value immediately, rather than indirecting through the address.
31
32; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(DW_OP_addr 0x0, DW_OP_stack_value)
33; CHECK-NOT: NULL
34
35; CHECK: DW_TAG_GNU_template_template_param
36; CHECK-NEXT: DW_AT_name{{.*}}= "y"
37; CHECK-NEXT: DW_AT_GNU_template_name{{.*}}= "y_impl"
38; CHECK-NOT: NULL
39
40; CHECK: DW_TAG_template_value_parameter
41; CHECK-NEXT: DW_AT_type{{.*}}=> {[[NULLPTR:0x[0-9a-f]*]]}
42; CHECK-NEXT: DW_AT_name{{.*}}= "n"
43; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata]{{.*}}(0)
44
45; CHECK: DW_TAG_GNU_template_parameter_pack
46; CHECK-NOT: NULL
47; CHECK: DW_TAG_template_value_parameter
48; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
49; CHECK-NEXT: DW_AT_const_value  [DW_FORM_sdata]{{.*}}(1)
50; CHECK-NOT: NULL
51; CHECK: DW_TAG_template_value_parameter
52; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
53; CHECK-NEXT: DW_AT_const_value  [DW_FORM_sdata]{{.*}}(2)
54
55; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type
56; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]}
57
58; CHECK: [[NULLPTR]]:{{ *}}DW_TAG_unspecified_type
59; CHECK-NEXT: DW_AT_name{{.*}}= "decltype(nullptr)"
60
61source_filename = "test/DebugInfo/X86/template.ll"
62
63%"struct.y_impl<int>::nested" = type { i8 }
64
65@glbl = global i32 0, align 4, !dbg !0
66@n = global %"struct.y_impl<int>::nested" zeroinitializer, align 1, !dbg !4
67@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_template.cpp, i8* null }]
68
69define internal void @__cxx_global_var_init() section ".text.startup" !dbg !17 {
70entry:
71  %call = call i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv(), !dbg !20
72  store i32 %call, i32* @glbl, align 4, !dbg !20
73  ret void, !dbg !20
74}
75
76; Function Attrs: nounwind uwtable
77define linkonce_odr i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv() #0 !dbg !21 {
78entry:
79  ret i32 3, !dbg !35
80}
81
82define internal void @_GLOBAL__sub_I_template.cpp() section ".text.startup" {
83entry:
84  call void @__cxx_global_var_init(), !dbg !36
85  ret void
86}
87
88attributes #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" }
89
90!llvm.dbg.cu = !{!11}
91!llvm.module.flags = !{!14, !15}
92!llvm.ident = !{!16}
93
94!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
95!1 = !DIGlobalVariable(name: "glbl", scope: null, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true)
96!2 = !DIFile(filename: "template.cpp", directory: "/tmp/dbginfo")
97!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
98!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
99!5 = !DIGlobalVariable(name: "n", scope: null, file: !2, line: 4, type: !6, isLocal: false, isDefinition: true)
100!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "nested", scope: !7, file: !2, line: 2, size: 8, align: 8, elements: !8, identifier: "_ZTSN6y_implIiE6nestedE")
101!7 = !DICompositeType(tag: DW_TAG_structure_type, name: "y_impl<int>", file: !2, line: 2, size: 8, align: 8, elements: !8, templateParams: !9, identifier: "_ZTS6y_implIiE")
102!8 = !{}
103!9 = !{!10}
104!10 = !DITemplateTypeParameter(type: !3)
105!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.6.0 (trunk 224394) (llvm/trunk 224384)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !8, retainedTypes: !12, globals: !13, imports: !8)
106!12 = !{!7, !6}
107!13 = !{!0, !4}
108!14 = !{i32 2, !"Dwarf Version", i32 4}
109!15 = !{i32 2, !"Debug Info Version", i32 3}
110!16 = !{!"clang version 3.6.0 (trunk 224394) (llvm/trunk 224384)"}
111!17 = distinct !DISubprogram(name: "__cxx_global_var_init", scope: !2, file: !2, line: 3, type: !18, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !11, retainedNodes: !8)
112!18 = !DISubroutineType(types: !19)
113!19 = !{null}
114!20 = !DILocation(line: 3, column: 12, scope: !17)
115!21 = distinct !DISubprogram(name: "func<3, &glbl, y_impl, nullptr, 1, 2>", linkageName: "_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv", scope: !2, file: !2, line: 1, type: !22, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !11, templateParams: !24, retainedNodes: !8)
116!22 = !DISubroutineType(types: !23)
117!23 = !{!3}
118!24 = !{!25, !26, !28, !29, !31}
119!25 = !DITemplateValueParameter(name: "x", type: !3, value: i32 3)
120!26 = !DITemplateValueParameter(type: !27, value: i32* @glbl)
121!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64)
122!28 = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "y", value: !"y_impl")
123!29 = !DITemplateValueParameter(name: "n", type: !30, value: i8 0)
124!30 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
125!31 = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "z", value: !32)
126!32 = !{!33, !34}
127!33 = !DITemplateValueParameter(type: !3, value: i32 1)
128!34 = !DITemplateValueParameter(type: !3, value: i32 2)
129!35 = !DILocation(line: 1, column: 96, scope: !21)
130!36 = !DILocation(line: 0, scope: !37)
131!37 = distinct !DISubprogram(linkageName: "_GLOBAL__sub_I_template.cpp", scope: !2, file: !2, type: !38, isLocal: true, isDefinition: true, flags: DIFlagArtificial, isOptimized: false, unit: !11, retainedNodes: !8)
132!38 = !DISubroutineType(types: !8)
133
134