Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_depend_codegen.cpp
blob83430dd97b073e2b1ff428fa910bcf9ef1d0348b
1 // Test host codegen.
2 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
3 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
5 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
6 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
9 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
10 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
11 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
12 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
13 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
14 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
15 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
17 // Test target codegen - host bc file has to be created first.
18 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
19 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
20 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
21 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
22 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
23 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
24 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
25 // RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
27 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
28 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
29 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
30 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
31 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
32 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
33 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
34 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
35 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
37 // expected-no-diagnostics
38 #ifndef HEADER
39 #define HEADER
41 // CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
42 // CHECK-DAG: [[ENTTY:%.+]] = type { ptr, ptr, i[[SZ:32|64]], i32, i32 }
44 // TCHECK: [[ENTTY:%.+]] = type { ptr, ptr, i{{32|64}}, i32, i32 }
46 // CHECK-DAG: [[SIZET:@.+]] = private unnamed_addr constant [3 x i64] [i64 0, i64 4, i64 {{16|12}}]
47 // CHECK-DAG: [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 544, i64 800, i64 3]
48 // CHECK-DAG: @{{.*}} = weak constant i8 0
50 // TCHECK: @{{.+}} = weak constant [[ENTTY]]
51 // TCHECK: @{{.+}} = {{.*}}constant [[ENTTY]]
52 // TCHECK-NOT: @{{.+}} = weak constant [[ENTTY]]
54 // Check target registration is registered as a Ctor.
55 // CHECK: appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null }]
58 template<typename tx, typename ty>
59 struct TT{
60 tx X;
61 ty Y;
64 #pragma omp declare mapper(id \
65 : TT <long long, char> \
66 s) map(s.X, s.Y)
67 int global;
68 extern int global;
70 // CHECK: define {{.*}}[[FOO:@.+]](
71 int foo(int n) {
72 int a = 0;
73 short aa = 0;
74 float b[10];
75 float bn[n];
76 double c[5][10];
77 double cn[5][n];
78 TT<long long, char> d;
79 static long *plocal;
81 // CHECK: [[ADD:%.+]] = add nsw i32
82 // CHECK: store i32 [[ADD]], ptr [[DEVICE_CAP:%.+]],
83 // CHECK: [[GEP:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i32 0, i32 0
84 // CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]],
85 // CHECK: store i32 [[DEV]], ptr [[GEP]],
86 // CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[GTID:%.+]], i32 1, i[[SZ]] {{20|40}}, i[[SZ]] 4, ptr [[TASK_ENTRY0:@.+]])
87 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1
88 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2
89 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 3
90 // CHECK: call void @__kmpc_omp_taskwait_deps_51(ptr @1, i32 [[GTID]], i32 4, ptr [[DEP_START]], i32 0, ptr null, i32 0)
91 // CHECK: call void @__kmpc_omp_task_begin_if0(ptr @1, i32 [[GTID]], ptr [[TASK]])
92 // CHECK: call i32 [[TASK_ENTRY0]](i32 [[GTID]], ptr [[TASK]])
93 // CHECK: call void @__kmpc_omp_task_complete_if0(ptr @1, i32 [[GTID]], ptr [[TASK]])
94 #pragma omp target device(global + a) depend(in \
95 : global) depend(out \
96 : a, b, cn[4])
100 // CHECK: [[ADD:%.+]] = add nsw i32
101 // CHECK: store i32 [[ADD]], ptr [[DEVICE_CAP:%.+]],
103 // CHECK: [[BOOL:%.+]] = icmp ne i32 %{{.+}}, 0
104 // CHECK: br i1 [[BOOL]], label %[[THEN:.+]], label %[[ELSE:.+]]
105 // CHECK: [[THEN]]:
106 // CHECK-DAG: [[BPADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP:%.+]], i32 0, i32 0
107 // CHECK-DAG: [[PADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P:%.+]], i32 0, i32 0
108 // CHECK-DAG: [[MADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M:%.+]], i[[SZ]] 0, i[[SZ]] 0
109 // CHECK-DAG: store ptr [[BP0:%[^,]+]], ptr [[BPADDR0]]
110 // CHECK-DAG: store ptr [[BP0]], ptr [[PADDR0]]
111 // CHECK-DAG: store ptr null, ptr [[MADDR0]],
113 // CHECK-DAG: [[BPADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 1
114 // CHECK-DAG: [[PADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 1
115 // CHECK-DAG: [[MADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M]], i[[SZ]] 0, i[[SZ]] 1
116 // CHECK-DAG: store i[[SZ]] [[BP1:%[^,]+]], ptr [[BPADDR1]]
117 // CHECK-DAG: store i[[SZ]] [[BP1]], ptr [[PADDR1]]
118 // CHECK-DAG: store ptr null, ptr [[MADDR1]],
120 // CHECK-DAG: [[BPADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 2
121 // CHECK-DAG: [[PADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 2
122 // CHECK-DAG: [[MADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M]], i[[SZ]] 0, i[[SZ]] 2
123 // CHECK-DAG: store ptr [[D_ADDR:%.+]], ptr [[BPADDR2]]
124 // CHECK-DAG: store ptr [[D_ADDR]], ptr [[PADDR2]]
125 // CHECK-DAG: store ptr [[MAPPER_ID:@.+]], ptr [[MADDR2]],
127 // CHECK-DAG: [[BP_START:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 0
128 // CHECK-DAG: [[P_START:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 0
129 // CHECK: [[GEP:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i32 0, i32 2
130 // CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]],
131 // CHECK: store i32 [[DEV]], ptr [[GEP]],
132 // CHECK: [[DEV1:%.+]] = load i32, ptr [[DEVICE_CAP]],
133 // CHECK: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
135 // CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_target_task_alloc(ptr @{{.*}}, i32 [[GTID]], i32 1, i[[SZ]] {{152|88}}, i[[SZ]] {{16|12}}, ptr [[TASK_ENTRY1_:@.+]], i64 [[DEV2]])
136 // CHECK: [[BASE:%.+]] = getelementptr inbounds [[TASK_TY1_:%.+]], ptr [[TASK]], i32 0, i32 1
137 // CHECK-64: [[BP_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 1
138 // CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[BP_BASE]], ptr align 8 [[BP_START]], i64 24, i1 false)
139 // CHECK-64: [[P_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 2
140 // CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[P_BASE]], ptr align 8 [[P_START]], i64 24, i1 false)
141 // CHECK-64: [[SZ_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 3
142 // CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[SZ_BASE]], ptr align 8 [[SIZET]], i64 24, i1 false)
143 // CHECK-64: [[M_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 4
144 // CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[M_BASE]], ptr align 8 [[M]], i64 24, i1 false)
145 // CHECK-32: [[SZ_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 0
146 // CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[SZ_BASE]], ptr align 4 [[SIZET]], i32 24, i1 false)
147 // CHECK-32: [[BP_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 3
148 // CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[BP_BASE]], ptr align 4 [[BP_START]], i32 12, i1 false)
149 // CHECK-32: [[P_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 4
150 // CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[P_BASE]], ptr align 4 [[P_START]], i32 12, i1 false)
151 // CHECK-32: [[M_BASE:%.+]] = getelementptr inbounds [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 5
152 // CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[M_BASE]], ptr align 4 [[M]], i32 12, i1 false)
153 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1
154 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2
155 // CHECK: call i32 @__kmpc_omp_task_with_deps(ptr @1, i32 [[GTID]], ptr [[TASK]], i32 3, ptr [[DEP_START]], i32 0, ptr null)
156 // CHECK: br label %[[EXIT:.+]]
158 // CHECK: [[ELSE]]:
159 // CHECK-NOT: getelementptr inbounds [2 x ptr], ptr
160 // CHECK: [[GEP:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i32 0, i32 2
161 // CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]],
162 // CHECK: store i32 [[DEV]], ptr [[GEP]],
163 // CHECK: [[DEV1:%.+]] = load i32, ptr [[DEVICE_CAP]],
164 // CHECK: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
166 // CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_target_task_alloc(ptr @1, i32 [[GTID]], i32 1, i[[SZ]] {{56|28}}, i[[SZ]] {{16|12}}, ptr [[TASK_ENTRY1__:@.+]], i64 [[DEV2]])
167 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1
168 // CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2
169 // CHECK: call i32 @__kmpc_omp_task_with_deps(ptr @1, i32 [[GTID]], ptr [[TASK]], i32 3, ptr [[DEP_START]], i32 0, ptr null)
170 // CHECK: br label %[[EXIT:.+]]
171 // CHECK: [[EXIT]]:
173 #pragma omp target device(global + a) nowait depend(inout \
174 : global, a, bn) if (a) map(mapper(id), tofrom \
175 : d)
177 static int local1;
178 *plocal = global;
179 local1 = global;
182 // CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[GTID]], i32 1, i[[SZ]] {{48|24}}, i[[SZ]] 4, ptr [[TASK_ENTRY2:@.+]])
183 // CHECK: call void @__kmpc_omp_taskwait_deps_51(ptr @1, i32 [[GTID]], i32 1, ptr %{{.+}}, i32 0, ptr null, i32 0)
184 // CHECK: call void @__kmpc_omp_task_begin_if0(ptr @1, i32 [[GTID]], ptr [[TASK]])
185 // CHECK: call i32 [[TASK_ENTRY2]](i32 [[GTID]], ptr [[TASK]])
186 // CHECK: call void @__kmpc_omp_task_complete_if0(ptr @1, i32 [[GTID]], ptr [[TASK]])
187 #pragma omp target if (0) firstprivate(global) depend(out \
188 : global)
190 global += 1;
193 return a;
196 // Check that the offloading functions are emitted and that the arguments are
197 // correct and loaded correctly for the target regions in foo().
199 // CHECK: define internal void [[HVT0:@.+]]()
201 // CHECK: define internal{{.*}} i32 [[TASK_ENTRY0]](i32{{.*}}, ptr noalias noundef %1)
202 // CHECK: store ptr null, ptr %
203 // CHECK: [[DEVICE_CAP:%.+]] = load ptr,
204 // CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]],
205 // CHECK: [[DEVICE:%.+]] = sext i32 [[DEV]] to i64
206 // CHECK: [[RET:%.+]] = call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 [[DEVICE]], i32 -1, i32 0, ptr @.[[TGT_REGION:.+]].region_id, ptr %[[KERNEL_ARGS:.+]])
207 // CHECK: [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
208 // CHECK: br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
209 // CHECK: [[FAIL]]
210 // CHECK: call void [[HVT0]]()
211 // CHECK: br label %[[END]]
212 // CHECK: [[END]]
213 // CHECK: ret i32 0
215 // CHECK: define internal void [[HVT1:@.+]](ptr noundef %{{.+}}, i[[SZ]] noundef %{{.+}})
217 // CHECK: define internal void [[MAPPER_ID]](ptr noundef %{{.+}}, ptr noundef %{{.+}}, ptr noundef %{{.+}}, i64 noundef %{{.+}}, i64 noundef %{{.+}})
219 // CHECK: define internal{{.*}} i32 [[TASK_ENTRY1_]](i32{{.*}}, ptr noalias noundef %{{.+}})
220 // CHECK: call void %{{.+}}(ptr %{{.+}}, ptr %{{.+}}, ptr %{{.+}}, ptr [[BPTR_ADDR:%.+]], ptr [[PTR_ADDR:%.+]], ptr [[SZ_ADDR:%.+]], ptr [[M_ADDR:%.+]])
221 // CHECK: [[BPTR_REF:%.+]] = load ptr, ptr [[BPTR_ADDR]],
222 // CHECK: [[PTR_REF:%.+]] = load ptr, ptr [[PTR_ADDR]],
223 // CHECK: [[SZ_REF:%.+]] = load ptr, ptr [[SZ_ADDR]],
224 // CHECK: [[M_REF:%.+]] = load ptr, ptr [[M_ADDR]],
225 // CHECK: [[DEVICE_CAP:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i32 0, i32 2
226 // CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]],
227 // CHECK: [[DEVICE:%.+]] = sext i32 [[DEV]] to i64
228 // CHECK: [[RET:%.+]] = call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 [[DEVICE]], i32 -1, i32 0, ptr @.[[TGT_REGION:.+]].region_id, ptr %[[KERNEL_ARGS:.+]])
230 // CHECK: [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
231 // CHECK: br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
232 // CHECK: [[FAIL]]
233 // CHECK: [[BP0:%.+]] = load ptr, ptr %
234 // CHECK: [[BP1_I32:%.+]] = load i32, ptr @
235 // CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
236 // CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
237 // CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]],
238 // CHECK: call void [[HVT1]](ptr [[BP0]], i[[SZ]] [[BP1]])
239 // CHECK: br label %[[END]]
240 // CHECK: [[END]]
241 // CHECK: ret i32 0
243 // CHECK: define internal{{.*}} i32 [[TASK_ENTRY1__]](i32{{.*}}, ptr noalias noundef %1)
244 // CHECK: call void {{%.*}}(
245 // CHECK: [[DEVICE_CAP:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i32 0, i32 2
246 // CHECK: [[BP0:%.+]] = load ptr, ptr %
247 // CHECK: [[BP1_I32:%.+]] = load i32, ptr @
248 // CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
249 // CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
250 // CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]],
251 // CHECK: call void [[HVT1]](ptr [[BP0]], i[[SZ]] [[BP1]])
252 // CHECK: ret i32 0
254 // CHECK: define internal void [[HVT2:@.+]](i[[SZ]] noundef %{{.+}})
255 // Create stack storage and store argument in there.
256 // CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]], align
257 // CHECK: store i[[SZ]] %{{.+}}, ptr [[AA_ADDR]], align
258 // CHECK-64: load i32, ptr [[AA_ADDR]], align
259 // CHECK-32: load i32, ptr [[AA_ADDR]], align
261 // CHECK: define internal{{.*}} i32 [[TASK_ENTRY2]](i32{{.*}}, ptr noalias noundef %1)
262 // CHECK: call void {{%.*}}(
263 // CHECK: [[BP1_I32:%.+]] = load i32, ptr %
264 // CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
265 // CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]],
266 // CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]],
267 // CHECK: call void [[HVT2]](i[[SZ]] [[BP1]])
268 // CHECK: ret i32 0
270 // CHECK: define internal void @.omp_offloading.requires_reg()
271 // CHECK: call void @__tgt_register_requires(i64 1)
272 // CHECK: ret void
274 #endif