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 operator T() { return T(); }
32 // CHECK-DAG: [[KMP_TASK_T_TY:%.+]] = type { ptr, ptr, i32, %union{{.+}}, %union{{.+}}, i64, i64, i64, i32, ptr }
33 // CHECK-DAG: [[S_DOUBLE_TY:%.+]] = type { double }
34 // CHECK-DAG: [[CAP_MAIN_TY:%.+]] = type { i8 }
35 // CHECK-DAG: [[PRIVATES_MAIN_TY:%.+]] = type {{.?}}{ [2 x [[S_DOUBLE_TY]]], [[S_DOUBLE_TY]], i32, [2 x i32]
36 // CHECK-DAG: [[KMP_TASK_MAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], [[PRIVATES_MAIN_TY]] }
37 // CHECK-DAG: [[S_INT_TY:%.+]] = type { i32 }
38 // CHECK-DAG: [[CAP_TMAIN_TY:%.+]] = type { i8 }
39 // CHECK-DAG: [[PRIVATES_TMAIN_TY:%.+]] = type { i32, [2 x i32], [2 x [[S_INT_TY]]], [[S_INT_TY]], [104 x i8] }
40 // CHECK-DAG: [[KMP_TASK_TMAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], [{{[0-9]+}} x i8], [[PRIVATES_TMAIN_TY]] }
44 T t_var
__attribute__((aligned(128))) = T();
46 S
<T
> s_arr
[] = {1, 2};
48 #pragma omp master taskloop private(t_var, vec, s_arr, s_arr, var, var)
49 for (int i
= 0; i
< 10; ++i
) {
59 // LAMBDA: [[G:@.+]] ={{.*}} global double
60 // LAMBDA-LABEL: @main
61 // LAMBDA: call{{( x86_thiscallcc)?}} void [[OUTER_LAMBDA:@.+]](
63 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
64 // LAMBDA: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
65 // LAMBDA: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i{{.+}} 0, i{{.+}} 1
66 // LAMBDA: call void @__kmpc_taskloop(ptr @{{.+}}, i32 %{{.+}}, ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr null)
68 #pragma omp master taskloop private(g, sivar)
69 for (int i
= 0; i
< 10; ++i
) {
70 // LAMBDA: define {{.+}} void [[INNER_LAMBDA:@.+]](ptr {{[^,]*}} [[ARG_PTR:%.+]])
71 // LAMBDA: store ptr [[ARG_PTR]], ptr [[ARG_PTR_REF:%.+]],
72 // LAMBDA: [[ARG_PTR:%.+]] = load ptr, ptr [[ARG_PTR_REF]]
73 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, ptr [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
74 // LAMBDA: [[G_REF:%.+]] = load ptr, ptr [[G_PTR_REF]]
75 // LAMBDA: store double 2.0{{.+}}, ptr [[G_REF]]
76 // LAMBDA: [[SIVAR_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, ptr [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
77 // LAMBDA: [[SIVAR_REF:%.+]] = load ptr, ptr [[SIVAR_PTR_REF]]
78 // LAMBDA: store i{{[0-9]+}} 3, ptr [[SIVAR_REF]]
80 // LAMBDA: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
83 // LAMBDA: store double 1.0{{.+}}, ptr %{{.+}},
84 // LAMBDA: store i{{[0-9]+}} 2, ptr %{{.+}},
85 // LAMBDA: call void [[INNER_LAMBDA]](ptr
95 // BLOCKS: [[G:@.+]] ={{.*}} global double
96 // BLOCKS: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
97 // BLOCKS-LABEL: @main
98 // BLOCKS: call void {{%.+}}(ptr
100 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(ptr
101 // BLOCKS: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
102 // BLOCKS: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, ptr %{{.+}}, i{{.+}} 0, i{{.+}} 1
103 // BLOCKS: call void @__kmpc_taskloop(ptr @{{.+}}, i32 %{{.+}}, ptr [[RES]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr null)
105 #pragma omp master taskloop private(g, sivar)
106 for (int i
= 0; i
< 10; ++i
) {
107 // BLOCKS: define {{.+}} void {{@.+}}(ptr
108 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
109 // BLOCKS: store double 2.0{{.+}}, ptr
110 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
111 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
112 // BLOCKS: store i{{[0-9]+}} 4, ptr
113 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
116 // BLOCKS: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
119 // BLOCKS: store double 1.0{{.+}}, ptr %{{.+}},
120 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
121 // BLOCKS: store i{{[0-9]+}} 3, ptr %{{.+}},
122 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
123 // BLOCKS: call void {{%.+}}(ptr
135 S
<double> s_arr
[] = {1, 2};
137 #pragma omp master taskloop private(var, t_var, s_arr, vec, s_arr, var, sivar)
138 for (int i
= 0; i
< 10; ++i
) {
149 // CHECK: define{{.*}} i{{[0-9]+}} @main()
150 // CHECK: [[TEST:%.+]] = alloca [[S_DOUBLE_TY]],
151 // CHECK: [[T_VAR_ADDR:%.+]] = alloca i32,
152 // CHECK: [[VEC_ADDR:%.+]] = alloca [2 x i32],
153 // CHECK: [[S_ARR_ADDR:%.+]] = alloca [2 x [[S_DOUBLE_TY]]],
154 // CHECK: [[VAR_ADDR:%.+]] = alloca [[S_DOUBLE_TY]],
155 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[LOC:@.+]])
157 // CHECK: call {{.*}} [[S_DOUBLE_TY_DEF_CONSTR:@.+]](ptr {{[^,]*}} [[TEST]])
159 // CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master(
160 // CHECK-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
161 // CHECK-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
163 // Do not store original variables in capture struct.
164 // CHECK-NOT: getelementptr inbounds [[CAP_MAIN_TY]],
167 // Returns struct kmp_task_t {
168 // [[KMP_TASK_T_TY]] task_data;
169 // [[KMP_TASK_MAIN_TY]] privates;
171 // CHECK: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr [[LOC]], i32 [[GTID]], i32 9, i64 120, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
173 // CHECK: [[TASK:%.+]] = getelementptr inbounds [[KMP_TASK_MAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
174 // Initialize kmp_task_t->privates with default values (no init for simple types, default constructors for classes).
175 // Also copy address of private copy to the corresponding shareds reference.
176 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_MAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
178 // Constructors for s_arr and var.
180 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
181 // CHECK: getelementptr inbounds [2 x [[S_DOUBLE_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
182 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} 2
183 // CHECK: call void [[S_DOUBLE_TY_DEF_CONSTR]](ptr {{[^,]*}} [[S_ARR_CUR:%.+]])
184 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr [[S_ARR_CUR]], i{{.+}} 1
189 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
190 // CHECK: call void [[S_DOUBLE_TY_DEF_CONSTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF:%.+]])
192 // Provide pointer to destructor function, which will destroy private variables at the end of the task.
193 // CHECK: [[DESTRUCTORS_REF:%.+]] = getelementptr inbounds [[KMP_TASK_T_TY]], ptr [[TASK]], i{{.+}} 0, i{{.+}} 3
194 // CHECK: store ptr [[DESTRUCTORS:@.+]], ptr [[DESTRUCTORS_REF]],
197 // 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:@.+]])
198 // CHECK: call {{.*}}void @__kmpc_end_master(
199 // CHECK-NEXT: br label {{%?}}[[EXIT]]
201 // CHECK: call i32 @__kmpc_omp_task(ptr [[LOC]], i32 [[GTID]], ptr
203 // CHECK: = call noundef i{{.+}} [[TMAIN_INT:@.+]]()
205 // No destructors must be called for private copies of s_arr and var.
206 // CHECK-NOT: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
207 // CHECK-NOT: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
208 // CHECK: call void [[S_DOUBLE_TY_DESTR:@.+]](ptr
209 // CHECK-NOT: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
210 // CHECK-NOT: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
214 // 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)
215 // CHECK: [[PRIVATES:%.+]] = load ptr, ptr
216 // CHECK: [[PRIV_S_VAR:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 0
217 // CHECK: [[ARG3:%.+]] = load ptr, ptr %{{.+}},
218 // CHECK: store ptr [[PRIV_S_VAR]], ptr [[ARG3]],
219 // CHECK: [[PRIV_VAR:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 1
220 // CHECK: [[ARG1:%.+]] = load ptr, ptr {{.+}},
221 // CHECK: store ptr [[PRIV_VAR]], ptr [[ARG1]],
222 // CHECK: [[PRIV_T_VAR:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 2
223 // CHECK: [[ARG2:%.+]] = load ptr, ptr %{{.+}},
224 // CHECK: store ptr [[PRIV_T_VAR]], ptr [[ARG2]],
225 // CHECK: [[PRIV_VEC:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i32 0, i32 3
226 // CHECK: [[ARG4:%.+]] = load ptr, ptr %{{.+}},
227 // CHECK: store ptr [[PRIV_VEC]], ptr [[ARG4]],
230 // CHECK: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
233 // CHECK: [[PRIV_VAR_ADDR:%.+]] = alloca ptr,
234 // CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,
235 // CHECK: [[PRIV_S_ARR_ADDR:%.+]] = alloca ptr,
236 // CHECK: [[PRIV_VEC_ADDR:%.+]] = alloca ptr,
237 // CHECK: [[PRIV_SIVAR_ADDR:%.+]] = alloca ptr,
238 // CHECK: store ptr [[PRIVATES_MAP_FN]], ptr [[MAP_FN_ADDR:%.+]],
239 // CHECK: [[MAP_FN:%.+]] = load ptr, ptr [[MAP_FN_ADDR]],
240 // 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]])
241 // CHECK: [[PRIV_VAR:%.+]] = load ptr, ptr [[PRIV_VAR_ADDR]],
242 // CHECK: [[PRIV_T_VAR:%.+]] = load ptr, ptr [[PRIV_T_VAR_ADDR]],
243 // CHECK: [[PRIV_S_ARR:%.+]] = load ptr, ptr [[PRIV_S_ARR_ADDR]],
244 // CHECK: [[PRIV_VEC:%.+]] = load ptr, ptr [[PRIV_VEC_ADDR]],
245 // CHECK: [[PRIV_SIVAR:%.+]] = load ptr, ptr [[PRIV_SIVAR_ADDR]],
247 // Privates actually are used.
248 // CHECK-DAG: [[PRIV_VAR]]
249 // CHECK-DAG: [[PRIV_T_VAR]]
250 // CHECK-DAG: [[PRIV_S_ARR]]
251 // CHECK-DAG: [[PRIV_VEC]]
252 // CHECK-DAG: [[PRIV_SIVAR]]
256 // CHECK: define internal void [[MAIN_DUP]](ptr noundef %0, ptr noundef %1, i32 noundef %2)
257 // CHECK: getelementptr inbounds [[KMP_TASK_MAIN_TY]], ptr %{{.+}}, i32 0, i32 1
258 // CHECK: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr %{{.+}}, i32 0, i32 0
259 // CHECK: getelementptr inbounds [2 x [[S_DOUBLE_TY]]], ptr %{{.+}}, i32 0, i32 0
260 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i64 2
264 // CHECK: call {{.*}} [[S_DOUBLE_TY_DEF_CONSTR]](ptr
265 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i64 1
266 // CHECK: icmp eq ptr %
269 // CHECK: getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr %{{.+}}, i32 0, i32 1
270 // CHECK: call {{.*}} [[S_DOUBLE_TY_DEF_CONSTR]](ptr
273 // CHECK: define internal noundef i32 [[DESTRUCTORS]](i32 noundef %0, ptr noalias noundef %1)
274 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_MAIN_TY]], ptr [[RES_KMP_TASK:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
275 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 0
276 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds [[PRIVATES_MAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
277 // CHECK: call void [[S_DOUBLE_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]])
278 // CHECK: getelementptr inbounds [2 x [[S_DOUBLE_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
279 // CHECK: getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} 2
280 // CHECK: [[PRIVATE_S_ARR_ELEM_REF:%.+]] = getelementptr inbounds [[S_DOUBLE_TY]], ptr %{{.+}}, i{{.+}} -1
281 // CHECK: call void [[S_DOUBLE_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_S_ARR_ELEM_REF]])
286 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
287 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
288 // CHECK: [[T_VAR_ADDR:%.+]] = alloca i32,
289 // CHECK: [[VEC_ADDR:%.+]] = alloca [2 x i32],
290 // CHECK: [[S_ARR_ADDR:%.+]] = alloca [2 x [[S_INT_TY]]],
291 // CHECK: [[VAR_ADDR:%.+]] = alloca [[S_INT_TY]],
292 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr [[LOC:@.+]])
294 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]](ptr {{[^,]*}} [[TEST]])
296 // Do not store original variables in capture struct.
297 // CHECK-NOT: getelementptr inbounds [[CAP_TMAIN_TY]],
300 // Returns struct kmp_task_t {
301 // [[KMP_TASK_T_TY]] task_data;
302 // [[KMP_TASK_TMAIN_TY]] privates;
304 // CHECK: [[RES:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr [[LOC]], i32 [[GTID]], i32 9, i64 256, i64 1, ptr [[TASK_ENTRY:@[^ ]+]])
306 // CHECK: [[TASK:%.+]] = getelementptr inbounds [[KMP_TASK_TMAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
308 // Initialize kmp_task_t->privates with default values (no init for simple types, default constructors for classes).
309 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_TMAIN_TY]], ptr [[RES]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
311 // Constructors for s_arr and var.
313 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
314 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
315 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} 2
316 // CHECK: call void [[S_INT_TY_DEF_CONSTR]](ptr {{[^,]*}} [[S_ARR_CUR:%.+]])
317 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr [[S_ARR_CUR]], i{{.+}} 1
322 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
323 // CHECK: call void [[S_INT_TY_DEF_CONSTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF:%.+]])
325 // Provide pointer to destructor function, which will destroy private variables at the end of the task.
326 // CHECK: [[DESTRUCTORS_REF:%.+]] = getelementptr inbounds [[KMP_TASK_T_TY]], ptr [[TASK]], i{{.+}} 0, i{{.+}} 3
327 // CHECK: store ptr [[DESTRUCTORS:@.+]], ptr [[DESTRUCTORS_REF]],
330 // 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:@.+]])
332 // No destructors must be called for private copies of s_arr and var.
333 // CHECK-NOT: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
334 // CHECK-NOT: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
335 // CHECK: call void [[S_INT_TY_DESTR:@.+]](ptr noundef
336 // CHECK-NOT: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
337 // CHECK-NOT: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
341 // 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)
342 // CHECK: [[PRIVATES:%.+]] = load ptr, ptr
343 // CHECK: [[PRIV_T_VAR:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 0
344 // CHECK: [[ARG1:%.+]] = load ptr, ptr %{{.+}},
345 // CHECK: store ptr [[PRIV_T_VAR]], ptr [[ARG1]],
346 // CHECK: [[PRIV_VEC:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 1
347 // CHECK: [[ARG2:%.+]] = load ptr, ptr %{{.+}},
348 // CHECK: store ptr [[PRIV_VEC]], ptr [[ARG2]],
349 // CHECK: [[PRIV_S_VAR:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 2
350 // CHECK: [[ARG3:%.+]] = load ptr, ptr %{{.+}},
351 // CHECK: store ptr [[PRIV_S_VAR]], ptr [[ARG3]],
352 // CHECK: [[PRIV_VAR:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i32 0, i32 3
353 // CHECK: [[ARG4:%.+]] = load ptr, ptr {{.+}},
354 // CHECK: store ptr [[PRIV_VAR]], ptr [[ARG4]],
357 // CHECK: define internal noundef i32 [[TASK_ENTRY]](i32 noundef %0, ptr noalias noundef %1)
360 // CHECK-DAG: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,
361 // CHECK-DAG: [[PRIV_VEC_ADDR:%.+]] = alloca ptr,
362 // CHECK-DAG: [[PRIV_S_ARR_ADDR:%.+]] = alloca ptr,
363 // CHECK-DAG: [[PRIV_VAR_ADDR:%.+]] = alloca ptr,
364 // CHECK: store ptr [[PRIVATES_MAP_FN]], ptr [[MAP_FN_ADDR:%.+]],
365 // CHECK: [[MAP_FN:%.+]] = load ptr, ptr [[MAP_FN_ADDR]],
366 // CHECK: call void [[MAP_FN]](ptr %{{.+}}, ptr [[PRIV_T_VAR_ADDR]], ptr [[PRIV_VEC_ADDR]], ptr [[PRIV_S_ARR_ADDR]], ptr [[PRIV_VAR_ADDR]])
367 // CHECK: [[PRIV_T_VAR:%.+]] = load ptr, ptr [[PRIV_T_VAR_ADDR]],
368 // CHECK: [[PRIV_VEC:%.+]] = load ptr, ptr [[PRIV_VEC_ADDR]],
369 // CHECK: [[PRIV_S_ARR:%.+]] = load ptr, ptr [[PRIV_S_ARR_ADDR]],
370 // CHECK: [[PRIV_VAR:%.+]] = load ptr, ptr [[PRIV_VAR_ADDR]],
372 // Privates actually are used.
373 // CHECK-DAG: [[PRIV_VAR]]
374 // CHECK-DAG: [[PRIV_T_VAR]]
375 // CHECK-DAG: [[PRIV_S_ARR]]
376 // CHECK-DAG: [[PRIV_VEC]]
380 // CHECK: define internal void [[TMAIN_DUP]](ptr noundef %0, ptr noundef %1, i32 noundef %2)
381 // CHECK: getelementptr inbounds [[KMP_TASK_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 2
382 // CHECK: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 2
383 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr %{{.+}}, i32 0, i32 0
384 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i64 2
388 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]](ptr
389 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i64 1
390 // CHECK: icmp eq ptr %
393 // CHECK: getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr %{{.+}}, i32 0, i32 3
394 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]](ptr
397 // CHECK: define internal noundef i32 [[DESTRUCTORS]](i32 noundef %0, ptr noalias noundef %1)
398 // CHECK: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_TMAIN_TY]], ptr [[RES_KMP_TASK:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
399 // CHECK: [[PRIVATE_S_ARR_REF:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
400 // CHECK: [[PRIVATE_VAR_REF:%.+]] = getelementptr inbounds [[PRIVATES_TMAIN_TY]], ptr [[PRIVATES]], i{{.+}} 0, i{{.+}} 3
401 // CHECK: call void [[S_INT_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_VAR_REF]])
402 // CHECK: getelementptr inbounds [2 x [[S_INT_TY]]], ptr [[PRIVATE_S_ARR_REF]], i{{.+}} 0, i{{.+}} 0
403 // CHECK: getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} 2
404 // CHECK: [[PRIVATE_S_ARR_ELEM_REF:%.+]] = getelementptr inbounds [[S_INT_TY]], ptr %{{.+}}, i{{.+}} -1
405 // CHECK: call void [[S_INT_TY_DESTR]](ptr {{[^,]*}} [[PRIVATE_S_ARR_ELEM_REF]])
412 // ARRAY-LABEL: array_func
416 St
&operator=(const St
&) { return *this; };
420 void array_func(int n
, float a
[n
], St s
[2]) {
421 // ARRAY: call ptr @__kmpc_omp_task_alloc(
422 // ARRAY: call void @__kmpc_taskloop(
423 // ARRAY: store ptr %{{.+}}, ptr %{{.+}},
424 // ARRAY: store ptr %{{.+}}, ptr %{{.+}},
425 #pragma omp master taskloop private(a, s)
426 for (int i
= 0; i
< 10; ++i
)