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