1 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
5 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
6 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
8 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
11 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
12 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
13 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
14 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
15 // expected-no-diagnostics
26 S(const S
&s
, T t
= T()) : f(s
.f
+ t
) {}
27 operator T() { return T(); }
33 // CHECK-DAG: [[KMP_TASK_T_TY:%.+]] = type { ptr, ptr, i32, %union{{.+}}, %union{{.+}}, i64, i64, i64, i32, ptr }
34 // CHECK-DAG: [[S_DOUBLE_TY:%.+]] = type { double }
35 // CHECK-DAG: [[PRIVATES_MAIN_TY:%.+]] = type {{.?}}{ [2 x [[S_DOUBLE_TY]]], [[S_DOUBLE_TY]], i32, [2 x i32]
36 // CHECK-DAG: [[CAP_MAIN_TY:%.+]] = type { ptr, ptr }
37 // CHECK-DAG: [[KMP_TASK_MAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], [[PRIVATES_MAIN_TY]] }
38 // CHECK-DAG: [[S_INT_TY:%.+]] = type { i32 }
39 // CHECK-DAG: [[CAP_TMAIN_TY:%.+]] = type { ptr, ptr }
40 // CHECK-DAG: [[PRIVATES_TMAIN_TY:%.+]] = type { i32, [2 x i32], [2 x [[S_INT_TY]]], [[S_INT_TY]], [104 x i8] }
41 // CHECK-DAG: [[KMP_TASK_TMAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], [{{[0-9]+}} x i8], [[PRIVATES_TMAIN_TY]] }
46 T t_var
__attribute__((aligned(128))) = T();
48 S
<T
> s_arr
[] = {1, 2};
50 #pragma omp taskloop simd firstprivate(t_var, vec, s_arr, s_arr, var, var)
51 for (int i
= 0; i
< 10; ++i
) {
61 // LAMBDA: [[G:@.+]] ={{.*}} global double
62 // LAMBDA: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
63 // LAMBDA-LABEL: @main
64 // LAMBDA: call{{( x86_thiscallcc)?}} void [[OUTER_LAMBDA:@.+]](
66 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
67 // LAMBDA: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
68 // LAMBDA: [[PRIVATES:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i{{.+}} 0, i{{.+}} 1
69 // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 0
70 // LAMBDA: [[G_VAL:%.+]] = load volatile double, ptr @{{.+}},
71 // LAMBDA: store volatile double [[G_VAL]], ptr [[G_PRIVATE_ADDR]]
73 // LAMBDA: [[SIVAR_PRIVATE_ADDR:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
74 // LAMBDA: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, ptr @{{.+}},
75 // LAMBDA: store i{{[0-9]+}} [[SIVAR_VAL]], ptr [[SIVAR_PRIVATE_ADDR]]
77 // LAMBDA: call void @__kmpc_taskloop(ptr @{{.+}}, i32 %{{.+}}, ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr null)
79 #pragma omp taskloop simd firstprivate(g, sivar)
80 for (int i
= 0; i
< 10; ++i
) {
81 // LAMBDA: define {{.+}} void [[INNER_LAMBDA:@.+]]({{.+}} [[ARG_PTR:%.+]])
82 // LAMBDA: store ptr [[ARG_PTR]], ptr [[ARG_PTR_REF:%.+]],
83 // LAMBDA: [[ARG_PTR:%.+]] = load ptr, ptr [[ARG_PTR_REF]]
84 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
85 // LAMBDA: [[G_REF:%.+]] = load ptr, ptr [[G_PTR_REF]]
86 // LAMBDA: store volatile double 2.0{{.+}}, ptr [[G_REF]]
88 // LAMBDA: store ptr %{{.+}}, ptr %{{.+}},
89 // LAMBDA: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
92 // LAMBDA: store double 1.0{{.+}}, ptr %{{.+}},
93 // LAMBDA: store i{{[0-9]+}} 11, ptr %{{.+}},
94 // LAMBDA: call void [[INNER_LAMBDA]]({{.+}}
103 #elif defined(BLOCKS)
104 // BLOCKS: [[G:@.+]] ={{.*}} global double
105 // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
106 // BLOCKS-LABEL: @main
107 // BLOCKS: call void {{%.+}}(ptr
109 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(ptr
110 // BLOCKS: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
111 // BLOCKS: [[PRIVATES:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i{{.+}} 0, i{{.+}} 1
112 // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 0
113 // BLOCKS: [[G_VAL:%.+]] = load volatile double, ptr @{{.+}},
114 // BLOCKS: store volatile double [[G_VAL]], ptr [[G_PRIVATE_ADDR]]
116 // BLOCKS: [[SIVAR_PRIVATE_ADDR:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
117 // BLOCKS: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, ptr @{{.+}},
118 // BLOCKS: store i{{[0-9]+}} [[SIVAR_VAL]], ptr [[SIVAR_PRIVATE_ADDR]]
119 // BLOCKS: call void @__kmpc_taskloop(ptr @{{.+}}, i32 %{{.+}}, ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr null)
121 #pragma omp taskloop simd firstprivate(g, sivar)
122 for (int i
= 0; i
< 10; ++i
) {
123 // BLOCKS: define {{.+}} void {{@.+}}(ptr
124 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
125 // BLOCKS: store volatile double 2.0{{.+}}, ptr
126 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
127 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
128 // BLOCKS: store i{{[0-9]+}} 22, ptr
129 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
132 // BLOCKS: store ptr %{{.+}}, ptr %{{.+}},
133 // BLOCKS: store ptr %{{.+}}, ptr %{{.+}},
134 // BLOCKS: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
137 // BLOCKS: store double 1.0{{.+}}, ptr %{{.+}},
138 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
139 // BLOCKS: store i{{[0-9]+}} 11, ptr %{{.+}},
140 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
141 // BLOCKS: call void {{%.+}}(ptr
154 S
<double> s_arr
[] = {1, 2};
156 #pragma omp taskloop simd firstprivate(var, t_var, s_arr, vec, s_arr, var, sivar)
157 for (int i
= 0; i
< 10; ++i
) {
166 // CHECK: [[SIVAR:.+]] = internal global i{{[0-9]+}} 0,
167 // CHECK: define{{.*}} i{{[0-9]+}} @main()
168 // CHECK: alloca [[S_DOUBLE_TY]],
169 // CHECK: [[TEST:%.+]] = alloca [[S_DOUBLE_TY]],
170 // CHECK: [[T_VAR_ADDR:%.+]] = alloca i32,
171 // CHECK: [[VEC_ADDR:%.+]] = alloca [2 x i32],
172 // CHECK: [[S_ARR_ADDR:%.+]] = alloca [2 x [[S_DOUBLE_TY]]],
173 // CHECK: [[VAR_ADDR:%.+]] = alloca [[S_DOUBLE_TY]],
174 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[LOC:@.+]])
176 // CHECK: call {{.*}} [[S_DOUBLE_TY_COPY_CONSTR:@.+]](ptr {{[^,]*}} [[TEST]],
178 // Store original variables in capture struct.
179 // CHECK: [[S_ARR_REF:%.+]] = getelementptr inbounds nuw [[CAP_MAIN_TY]], ptr %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
180 // CHECK: store ptr [[S_ARR_ADDR]], ptr [[S_ARR_REF]],
181 // CHECK: [[VAR_REF:%.+]] = getelementptr inbounds nuw [[CAP_MAIN_TY]], ptr %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 1
182 // CHECK: store ptr [[VAR_ADDR]], ptr [[VAR_REF]],
185 // Returns struct kmp_task_t {
186 // [[KMP_TASK_T]] task_data;
187 // [[KMP_TASK_MAIN_TY]] privates;
189 // CHECK: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr [[LOC]], i32 [[GTID]], i32 9, i64 120, i64 16, ptr [[TASK_ENTRY:@[^ ]+]])
191 // Fill kmp_task_t->shareds by copying from original capture argument.
192 // CHECK: [[TASK:%.+]] = getelementptr inbounds nuw [[KMP_TASK_MAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
193 // CHECK: [[SHAREDS_REF_ADDR:%.+]] = getelementptr inbounds nuw [[KMP_TASK_T_TY]], ptr [[TASK]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
194 // CHECK: [[SHAREDS_REF:%.+]] = load ptr, ptr [[SHAREDS_REF_ADDR]],
195 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[SHAREDS_REF]], ptr align 8 %{{.+}}, i64 16, i1 false)
197 // Initialize kmp_task_t->privates with default values (no init for simple types, default constructors for classes).
198 // Also copy address of private copy to the corresponding shareds reference.
199 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds nuw [[KMP_TASK_MAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
201 // Constructors for s_arr and var.
203 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
204 // CHECK: call void [[S_DOUBLE_TY_COPY_CONSTR]](ptr {{[^,]*}} [[S_ARR_CUR:%[^,]+]],
205 // CHECK: getelementptr [[S_DOUBLE_TY]], ptr [[S_ARR_CUR]], i{{.+}} 1
206 // CHECK: getelementptr [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} 1
211 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
212 // CHECK-NEXT: call void [[S_DOUBLE_TY_COPY_CONSTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]], ptr {{.*}},
215 // CHECK: [[PRIVATE_T_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
216 // CHECK-NEXT: [[T_VAR:%.+]] = load i32, ptr %{{.+}},
217 // CHECK-NEXT: store i32 [[T_VAR]], ptr [[PRIVATE_T_VAR_REF]],
220 // CHECK: [[PRIVATE_VEC_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
221 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(
224 // CHECK: [[PRIVATE_SIVAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 4
225 // CHECK: [[SIVAR:%.+]] = load i{{.+}}, ptr @{{.+}},
226 // CHECK: store i32 [[SIVAR]], ptr [[PRIVATE_SIVAR_REF]],
228 // Provide pointer to destructor function, which will destroy private variables at the end of the task.
229 // CHECK: [[DESTRUCTORS_REF:%.+]] = getelementptr inbounds nuw [[KMP_TASK_T_TY]], ptr [[TASK]], i{{.+}} 0, i{{.+}} 3
230 // CHECK: store ptr [[DESTRUCTORS:@.+]], ptr [[DESTRUCTORS_REF]],
233 // CHECK: call void @__kmpc_taskloop(ptr [[LOC]], i32 [[GTID]], ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr [[MAIN_DUP:@.+]])
235 // CHECK: = call noundef i{{.+}} [[TMAIN_INT:@.+]]()
237 // No destructors must be called for private copies of s_arr and var.
238 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
239 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
240 // CHECK: call void [[S_DOUBLE_TY_DESTR:@.+]](ptr
241 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
242 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
246 // CHECK: define internal void [[PRIVATES_MAP_FN:@.+]](ptr noalias noundef %0, ptr noalias noundef %1, ptr noalias noundef %2, ptr noalias noundef %3, ptr noalias noundef %4, ptr noalias noundef %5)
247 // CHECK: [[PRIVATES:%.+]] = load ptr, ptr
248 // CHECK: [[PRIV_S_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 0
249 // CHECK: [[ARG3:%.+]] = load ptr, ptr %{{.+}},
250 // CHECK: store ptr [[PRIV_S_VAR]], ptr [[ARG3]],
251 // CHECK: [[PRIV_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 1
252 // CHECK: [[ARG1:%.+]] = load ptr, ptr {{.+}},
253 // CHECK: store ptr [[PRIV_VAR]], ptr [[ARG1]],
254 // CHECK: [[PRIV_T_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 2
255 // CHECK: [[ARG2:%.+]] = load ptr, ptr %{{.+}},
256 // CHECK: store ptr [[PRIV_T_VAR]], ptr [[ARG2]],
257 // CHECK: [[PRIV_VEC:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 3
258 // CHECK: [[ARG4:%.+]] = load ptr, ptr %{{.+}},
259 // CHECK: store ptr [[PRIV_VEC]], ptr [[ARG4]],
260 // CHECK: [[PRIV_SIVAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 4
261 // CHECK: [[ARG5:%.+]] = load ptr, ptr %{{.+}},
262 // CHECK: store ptr [[PRIV_SIVAR]], ptr [[ARG5]],
265 // CHECK: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
268 // CHECK: [[PRIV_VAR_ADDR:%.+]] = alloca ptr,
269 // CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,
270 // CHECK: [[PRIV_S_ARR_ADDR:%.+]] = alloca ptr,
271 // CHECK: [[PRIV_VEC_ADDR:%.+]] = alloca ptr,
272 // CHECK: [[PRIV_SIVAR_ADDR:%.+]] = alloca ptr,
273 // CHECK: store ptr [[PRIVATES_MAP_FN]], ptr [[MAP_FN_ADDR:%.+]],
274 // CHECK: [[MAP_FN:%.+]] = load ptr, ptr [[MAP_FN_ADDR]],
276 // CHECK: call void [[MAP_FN]](ptr %{{.+}}, ptr [[PRIV_VAR_ADDR]], ptr [[PRIV_T_VAR_ADDR]], ptr [[PRIV_S_ARR_ADDR]], ptr [[PRIV_VEC_ADDR]], ptr [[PRIV_SIVAR_ADDR]])
278 // CHECK: [[PRIV_VAR:%.+]] = load ptr, ptr [[PRIV_VAR_ADDR]],
279 // CHECK: [[PRIV_T_VAR:%.+]] = load ptr, ptr [[PRIV_T_VAR_ADDR]],
280 // CHECK: [[PRIV_S_ARR:%.+]] = load ptr, ptr [[PRIV_S_ARR_ADDR]],
281 // CHECK: [[PRIV_VEC:%.+]] = load ptr, ptr [[PRIV_VEC_ADDR]],
282 // CHECK: [[PRIV_SIVAR:%.+]] = load ptr, ptr [[PRIV_SIVAR_ADDR]],
284 // Privates actually are used.
285 // CHECK-DAG: [[PRIV_VAR]]
286 // CHECK-DAG: [[PRIV_T_VAR]]
287 // CHECK-DAG: [[PRIV_S_ARR]]
288 // CHECK-DAG: [[PRIV_VEC]]
289 // CHECK-DAG: [[PRIV_SIVAR]]
293 // CHECK: define internal void [[MAIN_DUP]](ptr noundef %0, ptr noundef %1, i32 noundef %2)
294 // CHECK: getelementptr inbounds nuw [[KMP_TASK_MAIN_TY]], ptr %{{.+}}, i32 0, i32 1
295 // CHECK: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr %{{.+}}, i32 0, i32 0
296 // CHECK: getelementptr inbounds [2 x [[S_DOUBLE_TY]]], ptr %{{.+}}, i32 0, i32 0
297 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i64 2
301 // CHECK: call {{.*}} [[S_DOUBLE_TY_COPY_CONSTR]](ptr
302 // CHECK: getelementptr [[S_DOUBLE_TY]], ptr %{{.+}}, i32 1
303 // CHECK: icmp eq ptr %
306 // CHECK: getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr %{{.+}}, i32 0, i32 1
307 // CHECK: call {{.*}} [[S_DOUBLE_TY_COPY_CONSTR]](ptr
310 // CHECK: define internal noundef i32 [[DESTRUCTORS]](i32 noundef %0, ptr noalias noundef %1)
311 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds nuw [[KMP_TASK_MAIN_TY]], ptr [[RES_KMP_TASK:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
312 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 0
313 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
314 // CHECK: call void [[S_DOUBLE_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]])
315 // CHECK: getelementptr inbounds [2 x [[S_DOUBLE_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
316 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} 2
317 // CHECK: [[PRIVATE_S_ARR_ELEM_REF:%.+]] = getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} -1
318 // CHECK: call void [[S_DOUBLE_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_S_ARR_ELEM_REF]])
323 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
324 // CHECK: alloca [[S_INT_TY]],
325 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
326 // CHECK: [[T_VAR_ADDR:%.+]] = alloca i32, align 128
327 // CHECK: [[VEC_ADDR:%.+]] = alloca [2 x i32],
328 // CHECK: [[S_ARR_ADDR:%.+]] = alloca [2 x [[S_INT_TY]]],
329 // CHECK: [[VAR_ADDR:%.+]] = alloca [[S_INT_TY]],
330 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[LOC:@.+]])
332 // CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR:@.+]](ptr {{[^,]*}} [[TEST]],
334 // Store original variables in capture struct.
335 // CHECK: [[S_ARR_REF:%.+]] = getelementptr inbounds nuw [[CAP_TMAIN_TY]], ptr %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
336 // CHECK: store ptr [[S_ARR_ADDR]], ptr [[S_ARR_REF]],
337 // CHECK: [[VAR_REF:%.+]] = getelementptr inbounds nuw [[CAP_TMAIN_TY]], ptr %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 1
338 // CHECK: store ptr [[VAR_ADDR]], ptr [[VAR_REF]],
341 // Returns struct kmp_task_t {
342 // [[KMP_TASK_T_TY]] task_data;
343 // [[KMP_TASK_TMAIN_TY]] privates;
345 // CHECK: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr [[LOC]], i32 [[GTID]], i32 9, i64 256, i64 16, ptr [[TASK_ENTRY:@[^ ]+]])
347 // Fill kmp_task_t->shareds by copying from original capture argument.
348 // CHECK: [[TASK:%.+]] = getelementptr inbounds nuw [[KMP_TASK_TMAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
349 // CHECK: [[SHAREDS_REF_ADDR:%.+]] = getelementptr inbounds nuw [[KMP_TASK_T_TY]], ptr [[TASK]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
350 // CHECK: [[SHAREDS_REF:%.+]] = load ptr, ptr [[SHAREDS_REF_ADDR]],
351 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[SHAREDS_REF]], ptr align 8 %{{.+}}, i64 16, i1 false)
353 // Initialize kmp_task_t->privates with default values (no init for simple types, default constructors for classes).
354 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds nuw [[KMP_TASK_TMAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
357 // CHECK: [[PRIVATE_T_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 0
358 // CHECK-NEXT: [[T_VAR:%.+]] = load i32, ptr %{{.+}}, align 128
359 // CHECK-NEXT: store i32 [[T_VAR]], ptr [[PRIVATE_T_VAR_REF]], align 128
362 // CHECK: [[PRIVATE_VEC_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
363 // CHECK: call void @llvm.memcpy.p0.p0.i64(
365 // Constructors for s_arr and var.
367 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
368 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
369 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} 2
370 // CHECK: call void [[S_INT_TY_COPY_CONSTR]](ptr {{[^,]*}} [[S_ARR_CUR:%[^,]+]],
371 // CHECK: getelementptr [[S_INT_TY]], ptr [[S_ARR_CUR]], i{{.+}} 1
376 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
377 // CHECK-NEXT: call void [[S_INT_TY_COPY_CONSTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]],
379 // Provide pointer to destructor function, which will destroy private variables at the end of the task.
380 // CHECK: [[DESTRUCTORS_REF:%.+]] = getelementptr inbounds nuw [[KMP_TASK_T_TY]], ptr [[TASK]], i{{.+}} 0, i{{.+}} 3
381 // CHECK: store ptr [[DESTRUCTORS:@.+]], ptr [[DESTRUCTORS_REF]],
384 // CHECK: call void @__kmpc_taskloop(ptr [[LOC]], i32 [[GTID]], ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr [[TMAIN_DUP:@.+]])
386 // No destructors must be called for private copies of s_arr and var.
387 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
388 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
389 // CHECK: call void [[S_INT_TY_DESTR:@.+]](ptr noundef
390 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
391 // CHECK-NOT: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
395 // CHECK: define internal void [[PRIVATES_MAP_FN:@.+]](ptr noalias noundef %0, ptr noalias noundef %1, ptr noalias noundef %2, ptr noalias noundef %3, ptr noalias noundef %4)
396 // CHECK: [[PRIVATES:%.+]] = load ptr, ptr
397 // CHECK: [[PRIV_T_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 0
398 // CHECK: [[ARG1:%.+]] = load ptr, ptr %{{.+}},
399 // CHECK: store ptr [[PRIV_T_VAR]], ptr [[ARG1]],
400 // CHECK: [[PRIV_VEC:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 1
401 // CHECK: [[ARG2:%.+]] = load ptr, ptr %{{.+}},
402 // CHECK: store ptr [[PRIV_VEC]], ptr [[ARG2]],
403 // CHECK: [[PRIV_S_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 2
404 // CHECK: [[ARG3:%.+]] = load ptr, ptr %{{.+}},
405 // CHECK: store ptr [[PRIV_S_VAR]], ptr [[ARG3]],
406 // CHECK: [[PRIV_VAR:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 3
407 // CHECK: [[ARG4:%.+]] = load ptr, ptr {{.+}},
408 // CHECK: store ptr [[PRIV_VAR]], ptr [[ARG4]],
411 // CHECK: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
413 // CHECK-DAG: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,
414 // CHECK-DAG: [[PRIV_VEC_ADDR:%.+]] = alloca ptr,
415 // CHECK-DAG: [[PRIV_S_ARR_ADDR:%.+]] = alloca ptr,
416 // CHECK-DAG: [[PRIV_VAR_ADDR:%.+]] = alloca ptr,
417 // CHECK: store ptr [[PRIVATES_MAP_FN]], ptr [[MAP_FN_ADDR:%.+]],
418 // CHECK: [[MAP_FN:%.+]] = load ptr, ptr [[MAP_FN_ADDR]],
419 // CHECK: call void [[MAP_FN]](ptr %{{.+}}, ptr [[PRIV_T_VAR_ADDR]], ptr [[PRIV_VEC_ADDR]], ptr [[PRIV_S_ARR_ADDR]], ptr [[PRIV_VAR_ADDR]])
420 // CHECK: [[PRIV_T_VAR:%.+]] = load ptr, ptr [[PRIV_T_VAR_ADDR]],
421 // CHECK: [[PRIV_VEC:%.+]] = load ptr, ptr [[PRIV_VEC_ADDR]],
422 // CHECK: [[PRIV_S_ARR:%.+]] = load ptr, ptr [[PRIV_S_ARR_ADDR]],
423 // CHECK: [[PRIV_VAR:%.+]] = load ptr, ptr [[PRIV_VAR_ADDR]],
425 // Privates actually are used.
426 // CHECK-DAG: [[PRIV_VAR]]
427 // CHECK-DAG: [[PRIV_T_VAR]]
428 // CHECK-DAG: [[PRIV_S_ARR]]
429 // CHECK-DAG: [[PRIV_VEC]]
433 // CHECK: define internal void [[TMAIN_DUP]](ptr noundef %0, ptr noundef %1, i32 noundef %2)
434 // CHECK: getelementptr inbounds nuw [[KMP_TASK_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 2
435 // CHECK: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 2
436 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr %{{.+}}, i32 0, i32 0
437 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i64 2
441 // CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR]](ptr
442 // CHECK: getelementptr [[S_INT_TY]], ptr %{{.+}}, i32 1
443 // CHECK: icmp eq ptr %
446 // CHECK: getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 3
447 // CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR]](ptr
450 // CHECK: define internal noundef i32 [[DESTRUCTORS]](i32 noundef %0, ptr noalias noundef %1)
451 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds nuw [[KMP_TASK_TMAIN_TY]], ptr [[RES_KMP_TASK:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
452 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
453 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds nuw [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
454 // CHECK: call void [[S_INT_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]])
455 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
456 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} 2
457 // CHECK: [[PRIVATE_S_ARR_ELEM_REF:%.+]] = getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} -1
458 // CHECK: call void [[S_INT_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_S_ARR_ELEM_REF]])
465 // ARRAY-LABEL: array_func
473 void array_func(int n
, float a
[n
], St s
[2]) {
474 // ARRAY: call ptr @__kmpc_omp_task_alloc(
475 // ARRAY: call void @__kmpc_taskloop(
476 // ARRAY: store ptr %{{.+}}, ptr %{{.+}},
477 // ARRAY: store ptr %{{.+}}, ptr %{{.+}},
478 #pragma omp taskloop simd firstprivate(a, s)
479 for (int i
= 0; i
< 10; ++i
)