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