Debian Codegraph @

IGC/ocloc_tests/SPIRV-extenstions/SPV_INTEL_fpga_memory_attributes/annotate_attribute.ll

raw
1 ; UNSUPPORTED: system-windows
2 ; REQUIRES: llvm-spirv, regkeys, dg2-supported
3
4 ; RUN: llvm-as %s -o %t.bc
5 ; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_fpga_memory_accesses,+SPV_INTEL_fpga_memory_attributes -o %t.spv
6 ; RUN: ocloc compile -spirv_input -file %t.spv -device dg2 -options " -igc_opts 'ShaderDumpTranslationOnly=1'" 2>&1 | FileCheck %s --check-prefixes=CHECK-LLVM
7
8 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
9 target triple = "spir64-unknown-linux"
10
11 %class.anon = type { i8 }
12 %struct.bar = type { i32, i8, float, i8 }
13 %struct.S = type { i32 }
14 %struct.S.1 = type { i32 }
15 %struct.S.2 = type { i32 }
16
17 ; CHECK-LLVM-DAG: [[STR:@[0-9_.]+]] = {{.*}}42
18 ; CHECK-LLVM-DAG: [[STR2:@[0-9_.]+]] = {{.*}}{FOO}
19 ; CHECK-LLVM-DAG: [[STR3:@[0-9_.]+]] = {{.*}}bar
20 ; CHECK-LLVM-DAG: [[STR4:@[0-9_.]+]] = {{.*}}{baz}
21 ; CHECK-LLVM-DAG: [[STR5:@[0-9_.]+]] = {{.*}}128
22 ; CHECK-LLVM-DAG: [[STR6:@[0-9_.]+]] = {{.*}}qux
23 ; CHECK-LLVM-DAG: [[STR7:@[0-9_.]+]] = {{.*}}my_custom_annotations: 30, 60
24 ; CHECK-LLVM-DAG: [[STR8:@[0-9_.]+]] = {{.*}}my_custom_annotations: 20, 60, 80
25 ; CHECK-LLVM-DAG: [[STR9:@[0-9_.]+]] = {{.*}}annotation_with_zerointializer: 0, 0, 0
26 ; CHECK-LLVM-DAG: [[STR10:@[0-9_.]+]] = {{.*}}annotation_with_false: 0
27 ; CHECK-LLVM-DAG: [[STR11:@[0-9_.]+]] = {{.*}}"annotation_mixed: 0, 1, 0
28 @.str = private unnamed_addr constant [3 x i8] c"42\00", section "llvm.metadata"
29 @.str.1 = private unnamed_addr constant [23 x i8] c"annotate_attribute.cpp\00", section "llvm.metadata"
30 @.str.2 = private unnamed_addr constant [6 x i8] c"{FOO}\00", section "llvm.metadata"
31 @.str.3 = private unnamed_addr constant [4 x i8] c"bar\00", section "llvm.metadata"
32 @.str.4 = private unnamed_addr constant [6 x i8] c"{baz}\00", section "llvm.metadata"
33 @.str.5 = private unnamed_addr constant [4 x i8] c"128\00", section "llvm.metadata"
34 @.str.6 = private unnamed_addr constant [4 x i8] c"qux\00", section "llvm.metadata"
35 @.str.7 = private unnamed_addr constant [22 x i8] c"my_custom_annotations\00", section "llvm.metadata"
36 @.str.8 = private unnamed_addr constant [31 x i8] c"annotation_with_zerointializer\00", section "llvm.metadata"
37 @.str.9 = private unnamed_addr constant [22 x i8] c"annotation_with_false\00", section "llvm.metadata"
38 @.str.10 = private unnamed_addr constant [17 x i8] c"annotation_mixed\00", section "llvm.metadata"
39 @.args.0 = private unnamed_addr constant { i32, i32 } { i32 30, i32 60 }, section "llvm.metadata"
40 @.args.1 = private unnamed_addr constant { i32, i32, i32 } { i32 20, i32 60, i32 80 }, section "llvm.metadata"
41 @.args.2 = private unnamed_addr constant { i32, i32, i32 } zeroinitializer, section "llvm.metadata"
42 @.args.3 = private unnamed_addr constant { i1 } zeroinitializer, section "llvm.metadata"
43 @.args.4 = private unnamed_addr constant { i32, i32, i32 } { i32 0, i32 1, i32 0 }, section "llvm.metadata"
44
45
46 ; Function Attrs: nounwind
47 define spir_kernel void @_ZTSZ4mainE15kernel_function() #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 {
48 entry:
49 %0 = alloca %class.anon, align 1
50 %1 = bitcast %class.anon* %0 to i8*
51 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #4
52 call spir_func void @"_ZZ4mainENK3$_0clEv"(%class.anon* %0)
53 %2 = bitcast %class.anon* %0 to i8*
54 call void @llvm.lifetime.end.p0i8(i64 1, i8* %2) #4
55 ret void
56 }
57
58 ; Function Attrs: argmemonly nounwind
59 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
60
61 ; Function Attrs: inlinehint nounwind
62 define internal spir_func void @"_ZZ4mainENK3$_0clEv"(%class.anon* %this) #2 align 2 {
63 entry:
64 %this.addr = alloca %class.anon*, align 8
65 store %class.anon* %this, %class.anon** %this.addr, align 8, !tbaa !5
66 %this1 = load %class.anon*, %class.anon** %this.addr, align 8
67 call spir_func void @_Z3foov()
68 call spir_func void @_Z3bazv()
69 ret void
70 }
71
72 ; Function Attrs: argmemonly nounwind
73 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
74
75 ; Function Attrs: nounwind
76 define spir_func void @_Z3foov() #3 {
77 entry:
78 %var_one = alloca i32, align 4
79 %var_two = alloca i32, align 4
80 %var_three = alloca i8, align 1
81 %var_four = alloca i8, align 1
82 %0 = bitcast i32* %var_one to i8*
83 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #4
84 %var_one1 = bitcast i32* %var_one to i8*
85 ; CHECK-LLVM: call void @llvm.var.annotation(i8* %{{.*}}, i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[STR]], i32 0, i32 0), i8* undef, i32 undef, i8* undef)
86 call void @llvm.var.annotation(i8* %var_one1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 2, i8* undef)
87 %1 = bitcast i32* %var_two to i8*
88 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #4
89 %var_two2 = bitcast i32* %var_two to i8*
90 ; CHECK-LLVM: call void @llvm.var.annotation(i8* %{{.*}}, i8* getelementptr inbounds ([6 x i8], [6 x i8]* [[STR2]], i32 0, i32 0), i8* undef, i32 undef, i8* undef)
91 call void @llvm.var.annotation(i8* %var_two2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 3, i8* undef)
92 call void @llvm.lifetime.start.p0i8(i64 1, i8* %var_three) #4
93 ; CHECK-LLVM: call void @llvm.var.annotation(i8* %{{.*}}, i8* getelementptr inbounds ([4 x i8], [4 x i8]* [[STR3]], i32 0, i32 0), i8* undef, i32 undef, i8* undef)
94 call void @llvm.var.annotation(i8* %var_three, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 4, i8* undef)
95 call void @llvm.lifetime.end.p0i8(i64 1, i8* %var_three) #4
96 call void @llvm.lifetime.start.p0i8(i64 1, i8* %var_four) #4
97 ; CHECK-LLVM: call void @llvm.var.annotation(i8* %{{.*}}, i8* getelementptr inbounds ([30 x i8], [30 x i8]* [[STR7]], i32 0, i32 0), i8* undef, i32 undef, i8* undef)
98 call void @llvm.var.annotation(i8* %var_four, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 4, i8* bitcast ({ i32, i32 }* @.args.0 to i8*))
99 call void @llvm.lifetime.end.p0i8(i64 1, i8* %var_four) #4
100 %2 = bitcast i32* %var_two to i8*
101 call void @llvm.lifetime.end.p0i8(i64 4, i8* %2) #4
102 %3 = bitcast i32* %var_one to i8*
103 call void @llvm.lifetime.end.p0i8(i64 4, i8* %3) #4
104 ret void
105 }
106
107 ; Function Attrs: nounwind
108 declare void @llvm.var.annotation(i8*, i8*, i8*, i32, i8*) #4
109
110 ; Function Attrs: nounwind
111 define spir_func void @_Z3bazv() #3 {
112 entry:
113 %s1 = alloca %struct.bar, align 4
114 %0 = bitcast %struct.bar* %s1 to i8*
115 call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #4
116 ; CHECK-LLVM: %[[FIELD1:.*]] = getelementptr inbounds %struct.bar, %struct.bar* %{{[a-zA-Z0-9]+}}, i32 0, i32 0
117 ; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FIELD1]]{{.*}}[[STR4]]
118 %f1 = getelementptr inbounds %struct.bar, %struct.bar* %s1, i32 0, i32 0
119 %1 = call i32* @llvm.ptr.annotation.p0i32(i32* %f1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 8, i8* undef)
120 store i32 0, i32* %1, align 4, !tbaa !9
121 ; CHECK-LLVM: %[[FIELD2:.*]] = getelementptr inbounds %struct.bar, %struct.bar* %{{[a-zA-Z0-9]+}}, i32 0, i32 1
122 ; CHECK-LLVM: call i8* @llvm.ptr.annotation.p0i8{{.*}}%[[FIELD2]]{{.*}}[[STR5]]
123 %f2 = getelementptr inbounds %struct.bar, %struct.bar* %s1, i32 0, i32 1
124 %2 = call i8* @llvm.ptr.annotation.p0i8(i8* %f2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 9, i8* undef)
125 store i8 0, i8* %2, align 4, !tbaa !13
126 ; CHECK-LLVM: %[[FIELD3:.*]] = getelementptr inbounds %struct.bar, %struct.bar* %{{[a-zA-Z0-9]+}}, i32 0, i32 2
127 ; CHECK-LLVM: %[[CAST3:.*]] = bitcast{{.*}}%[[FIELD3]]
128 ; CHECK-LLVM: call i8* @llvm.ptr.annotation.p0i8{{.*}}%[[CAST3]]{{.*}}[[STR6]]
129 %f3 = getelementptr inbounds %struct.bar, %struct.bar* %s1, i32 0, i32 2
130 %3 = bitcast float* %f3 to i8*
131 %4 = call i8* @llvm.ptr.annotation.p0i8(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 9, i8* undef)
132 %5 = bitcast i8* %4 to float*
133 store float 0.000000e+00, float* %5, align 4, !tbaa !14
134 ; CHECK-LLVM: %[[FIELD4:.*]] = getelementptr inbounds %struct.bar, %struct.bar* %{{[a-zA-Z0-9]+}}, i32 0, i32 3
135 ; CHECK-LLVM: call i8* @llvm.ptr.annotation.p0i8{{.*}}%[[FIELD4]]{{.*}}[[STR8]]
136 %f4 = getelementptr inbounds %struct.bar, %struct.bar* %s1, i32 0, i32 3
137 %6 = call i8* @llvm.ptr.annotation.p0i8(i8* %f4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 9, i8* bitcast ({ i32, i32, i32 }* @.args.1 to i8*))
138 store i8 0, i8* %6, align 4, !tbaa !13
139 %7 = bitcast %struct.bar* %s1 to i8*
140 call void @llvm.lifetime.end.p0i8(i64 12, i8* %7) #4
141 ret void
142 }
143
144 ; Function Attrs: mustprogress noinline norecurse optnone uwtable
145 define dso_local noundef i32 @with_zeroinitializer() #0 {
146 entry:
147 %retval = alloca i32, align 4
148 %s = alloca %struct.S, align 4
149 store i32 0, i32* %retval, align 4
150 %a = getelementptr inbounds %struct.S, %struct.S* %s, i32 0, i32 0
151 %0 = call i32* @llvm.ptr.annotation.p0i32(i32* %a, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 3, i8* bitcast ({ i32, i32, i32 }* @.args.2 to i8*))
152 ; CHECK-LLVM: %[[FIELD5:.*]] = getelementptr inbounds %struct.S, %struct.S* %{{[a-z]+}}, i32 0, i32 0
153 ; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FIELD5]]{{.*}}[[STR9]]
154 %1 = load i32, i32* %0, align 4
155 call void @_Z3fooi(i32 noundef %1)
156 ret i32 0
157 }
158
159 ; Function Attrs: mustprogress noinline norecurse optnone uwtable
160 define dso_local noundef i32 @with_false() #0 {
161 entry:
162 %retval = alloca i32, align 4
163 %s = alloca %struct.S.1, align 4
164 store i32 0, i32* %retval, align 4
165 %a = getelementptr inbounds %struct.S.1, %struct.S.1* %s, i32 0, i32 0
166 %0 = call i32* @llvm.ptr.annotation.p0i32(i32* %a, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 3, i8* bitcast ({ i1 }* @.args.3 to i8*))
167 ; CHECK-LLVM: %[[FIELD6:.*]] = getelementptr inbounds %struct.S.1, %struct.S.1* %{{[a-z]+}}, i32 0, i32 0
168 ; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FIELD6]]{{.*}}[[STR10]]
169 %1 = load i32, i32* %0, align 4
170 call void @_Z3fooi(i32 noundef %1)
171 ret i32 0
172 }
173
174 ; Function Attrs: mustprogress noinline norecurse optnone uwtable
175 define dso_local noundef i32 @mixed() #0 {
176 entry:
177 %retval = alloca i32, align 4
178 %s = alloca %struct.S.2, align 4
179 store i32 0, i32* %retval, align 4
180 %a = getelementptr inbounds %struct.S.2, %struct.S.2* %s, i32 0, i32 0
181 %0 = call i32* @llvm.ptr.annotation.p0i32(i32* %a, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i32 3, i8* bitcast ({ i32, i32, i32 }* @.args.4 to i8*))
182 ; CHECK-LLVM: %[[FIELD7:.*]] = getelementptr inbounds %struct.S.2, %struct.S.2* %{{[a-z]+}}, i32 0, i32 0
183 ; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FIELD7]]{{.*}}[[STR11]]
184 %1 = load i32, i32* %0, align 4
185 call void @_Z3fooi(i32 noundef %1)
186 ret i32 0
187 }
188
189 declare dso_local void @_Z3fooi(i32 noundef)
190
191 ; Function Attrs: nounwind
192 declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*) #4
193
194 ; Function Attrs: nounwind
195 declare i32* @llvm.ptr.annotation.p0i32(i32*, i8*, i8*, i32, i8*) #4
196
197 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
198 attributes #1 = { argmemonly nounwind }
199 attributes #2 = { inlinehint nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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" }
200 attributes #3 = { nounwind optnone noinline "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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" }
201 attributes #4 = { nounwind }
202
203 !llvm.module.flags = !{!0}
204 !opencl.spir.version = !{!1}
205 !spirv.Source = !{!2}
206 !llvm.ident = !{!3}
207
208 !0 = !{i32 1, !"wchar_size", i32 4}
209 !1 = !{i32 1, i32 2}
210 !2 = !{i32 4, i32 100000}
211 !3 = !{!"clang version 9.0.0"}
212 !4 = !{}
213 !5 = !{!6, !6, i64 0}
214 !6 = !{!"any pointer", !7, i64 0}
215 !7 = !{!"omnipotent char", !8, i64 0}
216 !8 = !{!"Simple C++ TBAA"}
217 !9 = !{!10, !11, i64 0}
218 !10 = !{!"_ZTS3bar", !11, i64 0, !7, i64 4, !12, i64 8}
219 !11 = !{!"int", !7, i64 0}
220 !12 = !{!"float", !7, i64 0}
221 !13 = !{!10, !7, i64 4}
222 !14 = !{!10, !12, i64 8}