Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/RecursiveDebugInfo.ll

raw
1 ; Test checks that the translator converts debug info correctly and
2 ; doesn't crash if the module has recursive template parameters definition.
3
4 ; This LLVM IR was generated using Intel SYCL Clang compiler (https://github.com/intel/llvm)
5
6 ; recursive_debug_info.cpp:
7 ;
8 ; namespace s = cl::sycl;
9 ;
10 ; template<typename Container>
11 ; struct iterator {
12 ; int *Itr;
13 ; iterator() : Itr(nullptr) {}
14 ; iterator(int* itr) : Itr(itr) {}
15 ; };
16 ;
17 ; struct vector {
18 ; int *Start;
19 ; typedef iterator<vector> vec_it;
20 ; vec_it begin() {
21 ; return vec_it(Start);
22 ; }
23 ; };
24 ;
25 ; class foo;
26 ;
27 ; int main() {
28 ; s::queue q;
29 ; auto e = q.submit([=](s::handler &cgh) {
30 ; cgh.single_task<class foo>([=]() {
31 ; iterator<vector> IV;
32 ; vector V;
33 ; });
34 ; });
35 ; e.wait();
36 ; return 0;
37 ; }
38
39 ; RUN: llvm-as %s -o %t.bc
40 ; RUN: llvm-spirv %t.bc -o %t.spv
41 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
42 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s
43
44 ; CHECK: [[IT_VEC:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "iterator<vector>", {{.+}}, templateParams: [[TMPL_P:![0-9]+]]
45 ; CHECK: [[TMPL_P]] = !{[[TMPL_P1:![0-9]+]]}
46 ; CHECK: [[TMPL_P1]] = !DITemplateTypeParameter(name: "Container", type: [[CTNR_TY:![0-9]+]])
47 ; CHECK: [[CTNR_TY]] = !DICompositeType(tag: DW_TAG_structure_type, name: "vector", {{.+}}, elements: [[ELMS:![0-9]+]]
48 ; CHECK: [[ELMS]] = !{!{{[0-9]+}}, [[EL2:![0-9]+]]}
49 ; CHECK: [[EL2]] = !DISubprogram(name: "begin", {{.+}}, type: [[SPRG_TY:![0-9]+]]
50 ; CHECK: [[SPRG_TY]] = !DISubroutineType(types: [[FNC_TYS:![0-9]+]])
51 ; CHECK: [[FNC_TYS]] = !{[[FNC_TY1:![0-9]+]], !{{[0-9]+}}}
52 ; CHECK: [[FNC_TY1]] = !DIDerivedType(tag: DW_TAG_typedef, name: "vec_it", {{.+}}, baseType: [[IT_VEC]])
53
54 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
55 target triple = "spir64-unknown-unknown"
56
57 %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" = type { i8 }
58 %struct._ZTS8iteratorI6vectorE.iterator = type { i32 addrspace(4)* }
59 %struct._ZTS6vector.vector = type { i32 addrspace(4)* }
60
61 $_ZTS3foo = comdat any
62
63 $_ZN8iteratorI6vectorEC2Ev = comdat any
64
65 define weak_odr dso_local spir_kernel void @_ZTS3foo() #0 comdat !dbg !12 !kernel_arg_addr_space !10 !kernel_arg_access_qual !10 !kernel_arg_type !10 !kernel_arg_base_type !10 !kernel_arg_type_qual !10 !kernel_arg_host_accessible !10 !kernel_arg_pipe_depth !10 !kernel_arg_pipe_io !10 !kernel_arg_buffer_location !10 {
66 entry:
67 %0 = alloca %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon", align 1
68 %1 = bitcast %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon"* %0 to i8*
69 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #5
70 call void @llvm.dbg.declare(metadata %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon"* %0, metadata !15, metadata !DIExpression()), !dbg !23
71 %2 = addrspacecast %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon"* %0 to %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)*, !dbg !24
72 call spir_func void @"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlvE_clEv"(%"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)* %2), !dbg !24
73 %3 = bitcast %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon"* %0 to i8*, !dbg !23
74 call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #5, !dbg !23
75 ret void
76 }
77
78 ; Function Attrs: argmemonly nounwind willreturn
79 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
80
81 ; Function Attrs: nounwind readnone speculatable willreturn
82 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
83
84 ; Function Attrs: inlinehint
85 define internal spir_func void @"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlvE_clEv"(%"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)* %this) #3 align 2 !dbg !26 {
86 entry:
87 %this.addr = alloca %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)*, align 8
88 %IV = alloca %struct._ZTS8iteratorI6vectorE.iterator, align 8
89 %V = alloca %struct._ZTS6vector.vector, align 8
90 store %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)* %this, %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)** %this.addr, align 8, !tbaa !52
91 call void @llvm.dbg.declare(metadata %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" addrspace(4)** %this.addr, metadata !28, metadata !DIExpression()), !dbg !56
92 %0 = bitcast %struct._ZTS8iteratorI6vectorE.iterator* %IV to i8*, !dbg !57
93 call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #5, !dbg !57
94 call void @llvm.dbg.declare(metadata %struct._ZTS8iteratorI6vectorE.iterator* %IV, metadata !30, metadata !DIExpression()), !dbg !58
95 %1 = addrspacecast %struct._ZTS8iteratorI6vectorE.iterator* %IV to %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)*, !dbg !58
96 call spir_func void @_ZN8iteratorI6vectorEC2Ev(%struct._ZTS8iteratorI6vectorE.iterator addrspace(4)* %1), !dbg !58
97 %2 = bitcast %struct._ZTS6vector.vector* %V to i8*, !dbg !59
98 call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #5, !dbg !59
99 call void @llvm.dbg.declare(metadata %struct._ZTS6vector.vector* %V, metadata !51, metadata !DIExpression()), !dbg !60
100 %3 = bitcast %struct._ZTS6vector.vector* %V to i8*, !dbg !61
101 call void @llvm.lifetime.end.p0i8(i64 8, i8* %3) #5, !dbg !61
102 %4 = bitcast %struct._ZTS8iteratorI6vectorE.iterator* %IV to i8*, !dbg !61
103 call void @llvm.lifetime.end.p0i8(i64 8, i8* %4) #5, !dbg !61
104 ret void, !dbg !61
105 }
106
107 ; Function Attrs: argmemonly nounwind willreturn
108 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
109
110 ; Function Attrs: nounwind
111 define linkonce_odr dso_local spir_func void @_ZN8iteratorI6vectorEC2Ev(%struct._ZTS8iteratorI6vectorE.iterator addrspace(4)* %this) unnamed_addr #4 comdat align 2 !dbg !62 {
112 entry:
113 %this.addr = alloca %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)*, align 8
114 store %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)* %this, %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)** %this.addr, align 8, !tbaa !52
115 call void @llvm.dbg.declare(metadata %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)** %this.addr, metadata !64, metadata !DIExpression()), !dbg !66
116 %this1 = load %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)*, %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)** %this.addr, align 8
117 %Itr = getelementptr inbounds %struct._ZTS8iteratorI6vectorE.iterator, %struct._ZTS8iteratorI6vectorE.iterator addrspace(4)* %this1, i32 0, i32 0, !dbg !67
118 store i32 addrspace(4)* null, i32 addrspace(4)* addrspace(4)* %Itr, align 8, !dbg !67, !tbaa !68
119 ret void, !dbg !70
120 }
121
122 attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "sycl-module-id"="recursive_debug_info.cpp" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
123 attributes #1 = { argmemonly nounwind willreturn }
124 attributes #2 = { nounwind readnone speculatable willreturn }
125 attributes #3 = { inlinehint "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
126 attributes #4 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
127 attributes #5 = { nounwind }
128
129 !llvm.dbg.cu = !{!0}
130 !llvm.module.flags = !{!5, !6, !7}
131 !opencl.spir.version = !{!8}
132 !spirv.Source = !{!9}
133 !opencl.used.extensions = !{!10}
134 !opencl.used.optional.core.features = !{!10}
135 !opencl.compiler.options = !{!10}
136 !llvm.ident = !{!11}
137
138 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
139 !1 = !DIFile(filename: "recursive_debug_info.cpp", directory: "/localdisk/test")
140 !2 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
141 !3 = !{null}
142 !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64)
143 !5 = !{i32 7, !"Dwarf Version", i32 4}
144 !6 = !{i32 2, !"Debug Info Version", i32 3}
145 !7 = !{i32 1, !"wchar_size", i32 4}
146 !8 = !{i32 1, i32 2}
147 !9 = !{i32 4, i32 100000}
148 !10 = !{}
149 !11 = !{!"clang version 10.0.0"}
150 !12 = distinct !DISubprogram(name: "_ZTS3foo", scope: !1, file: !1, line: 28, type: !13, flags: DIFlagArtificial | DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
151 !13 = !DISubroutineType(cc: DW_CC_LLVM_OpenCLKernel, types: !3)
152 !14 = !{!15}
153 !15 = !DILocalVariable(scope: !12, file: !1, type: !16)
154 !16 = distinct !DICompositeType(tag: DW_TAG_class_type, file: !1, line: 28, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !17)
155 !17 = !{!18}
156 !18 = !DISubprogram(name: "operator()", scope: !16, file: !1, line: 28, type: !19, scopeLine: 28, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagOptimized)
157 !19 = !DISubroutineType(cc: DW_CC_LLVM_SpirFunction, types: !20)
158 !20 = !{null, !21}
159 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
160 !22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !16)
161 !23 = !DILocation(line: 0, scope: !12)
162 !24 = !DILocation(line: 0, scope: !25)
163 !25 = distinct !DILexicalBlock(scope: !12, file: !1)
164 !26 = distinct !DISubprogram(name: "operator()", linkageName: "_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlvE_clEv", scope: !16, file: !1, line: 28, type: !19, scopeLine: 28, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !18, retainedNodes: !27)
165 !27 = !{!28, !30, !51}
166 !28 = !DILocalVariable(name: "this", arg: 1, scope: !26, type: !29, flags: DIFlagArtificial | DIFlagObjectPointer)
167 !29 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64)
168 !30 = !DILocalVariable(name: "IV", scope: !26, file: !1, line: 29, type: !31)
169 !31 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "iterator<vector>", file: !1, line: 6, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !32, templateParams: !41, identifier: "_ZTS8iteratorI6vectorE")
170 !32 = !{!33, !34, !38}
171 !33 = !DIDerivedType(tag: DW_TAG_member, name: "Itr", scope: !31, file: !1, line: 7, baseType: !4, size: 64)
172 !34 = !DISubprogram(name: "iterator", scope: !31, file: !1, line: 9, type: !35, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
173 !35 = !DISubroutineType(cc: DW_CC_LLVM_SpirFunction, types: !36)
174 !36 = !{null, !37}
175 !37 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !31, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
176 !38 = !DISubprogram(name: "iterator", scope: !31, file: !1, line: 10, type: !39, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
177 !39 = !DISubroutineType(cc: DW_CC_LLVM_SpirFunction, types: !40)
178 !40 = !{null, !37, !4}
179 !41 = !{!42}
180 !42 = !DITemplateTypeParameter(name: "Container", type: !43)
181 !43 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "vector", file: !1, line: 13, size: 64, flags: DIFlagTypePassByValue, elements: !44, identifier: "_ZTS6vector")
182 !44 = !{!45, !46}
183 !45 = !DIDerivedType(tag: DW_TAG_member, name: "Start", scope: !43, file: !1, line: 14, baseType: !4, size: 64)
184 !46 = !DISubprogram(name: "begin", linkageName: "_ZN6vector5beginEv", scope: !43, file: !1, line: 18, type: !47, scopeLine: 18, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
185 !47 = !DISubroutineType(cc: DW_CC_LLVM_SpirFunction, types: !48)
186 !48 = !{!49, !50}
187 !49 = !DIDerivedType(tag: DW_TAG_typedef, name: "vec_it", scope: !43, file: !1, line: 16, baseType: !31)
188 !50 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !43, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
189 !51 = !DILocalVariable(name: "V", scope: !26, file: !1, line: 30, type: !43)
190 !52 = !{!53, !53, i64 0}
191 !53 = !{!"any pointer", !54, i64 0}
192 !54 = !{!"omnipotent char", !55, i64 0}
193 !55 = !{!"Simple C++ TBAA"}
194 !56 = !DILocation(line: 0, scope: !26)
195 !57 = !DILocation(line: 29, column: 7, scope: !26)
196 !58 = !DILocation(line: 29, column: 24, scope: !26)
197 !59 = !DILocation(line: 30, column: 7, scope: !26)
198 !60 = !DILocation(line: 30, column: 14, scope: !26)
199 !61 = !DILocation(line: 31, column: 5, scope: !26)
200 !62 = distinct !DISubprogram(name: "iterator", linkageName: "_ZN8iteratorI6vectorEC2Ev", scope: !31, file: !1, line: 9, type: !35, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !34, retainedNodes: !63)
201 !63 = !{!64}
202 !64 = !DILocalVariable(name: "this", arg: 1, scope: !62, type: !65, flags: DIFlagArtificial | DIFlagObjectPointer)
203 !65 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !31, size: 64)
204 !66 = !DILocation(line: 0, scope: !62)
205 !67 = !DILocation(line: 9, column: 16, scope: !62)
206 !68 = !{!69, !53, i64 0}
207 !69 = !{!"_ZTS8iteratorI6vectorE", !53, i64 0}
208 !70 = !DILocation(line: 9, column: 30, scope: !62)