blob: 809edf8fc39a3a78bad82de89fa0175c9c18ab6c [file] [log] [blame]
Alexey Bataevdb390212015-05-20 04:24:19 +00001// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
2// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
3// RUN: %clang_cc1 -fopenmp -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
5// RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
6// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
Alexey Bataev4a5bb772014-10-08 14:01:46 +00007// expected-no-diagnostics
Alexey Bataev1d9c15c2015-05-19 12:31:28 +00008#ifndef ARRAY
Alexey Bataev4a5bb772014-10-08 14:01:46 +00009#ifndef HEADER
10#define HEADER
11
12struct St {
13 int a, b;
14 St() : a(0), b(0) {}
15 St(const St &st) : a(st.a + st.b), b(0) {}
16 ~St() {}
17};
18
Alexey Bataev1d7f0fa2015-09-10 09:48:30 +000019volatile int g __attribute__((aligned(128))) = 1212;
Alexey Bataev4a5bb772014-10-08 14:01:46 +000020
Alexey Bataev417089f2016-02-17 13:19:37 +000021struct SS {
22 int a;
23 int b : 4;
24 int &c;
Alexey Bataevfeddd642016-04-22 09:05:03 +000025 int e[4];
Alexey Bataev417089f2016-02-17 13:19:37 +000026 SS(int &d) : a(0), b(0), c(d) {
Alexey Bataevfeddd642016-04-22 09:05:03 +000027#pragma omp parallel firstprivate(a, b, c, e)
Alexey Bataev417089f2016-02-17 13:19:37 +000028#ifdef LAMBDA
29 [&]() {
30 ++this->a, --b, (this)->c /= 1;
31#pragma omp parallel firstprivate(a, b, c)
32 ++(this)->a, --b, this->c /= 1;
33 }();
34#elif defined(BLOCKS)
35 ^{
36 ++a;
37 --this->b;
38 (this)->c /= 1;
39#pragma omp parallel firstprivate(a, b, c)
40 ++(this)->a, --b, this->c /= 1;
41 }();
42#else
Alexey Bataevfeddd642016-04-22 09:05:03 +000043 ++this->a, --b, c /= 1, e[2] = 1111;
Alexey Bataev417089f2016-02-17 13:19:37 +000044#endif
45 }
46};
47
48template<typename T>
49struct SST {
50 T a;
51 SST() : a(T()) {
52#pragma omp parallel firstprivate(a)
53#ifdef LAMBDA
54 [&]() {
55 [&]() {
56 ++this->a;
57#pragma omp parallel firstprivate(a)
58 ++(this)->a;
59 }();
60 }();
61#elif defined(BLOCKS)
62 ^{
63 ^{
64 ++a;
65#pragma omp parallel firstprivate(a)
66 ++(this)->a;
67 }();
68 }();
69#else
70 ++(this)->a;
71#endif
72 }
73};
74
Alexey Bataev4a5bb772014-10-08 14:01:46 +000075template <class T>
76struct S {
77 T f;
78 S(T a) : f(a + g) {}
79 S() : f(g) {}
80 S(const S &s, St t = St()) : f(s.f + t.a) {}
81 operator T() { return T(); }
82 ~S() {}
83};
84
Alexey Bataev417089f2016-02-17 13:19:37 +000085// CHECK: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
86// LAMBDA: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
87// BLOCKS: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
Alexey Bataev4a5bb772014-10-08 14:01:46 +000088// CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
89// CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
90// CHECK-DAG: [[ST_TY:%.+]] = type { i{{[0-9]+}}, i{{[0-9]+}} }
Alexey Bataev4a5bb772014-10-08 14:01:46 +000091
92template <typename T>
93T tmain() {
94 S<T> test;
Alexey Bataev417089f2016-02-17 13:19:37 +000095 SST<T> sst;
Alexey Bataev1d7f0fa2015-09-10 09:48:30 +000096 T t_var __attribute__((aligned(128))) = T();
97 T vec[] __attribute__((aligned(128))) = {1, 2};
98 S<T> s_arr[] __attribute__((aligned(128))) = {1, 2};
99 S<T> var __attribute__((aligned(128))) (3);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000100#pragma omp parallel firstprivate(t_var, vec, s_arr, var)
101 {
102 vec[0] = t_var;
103 s_arr[0] = var;
104 }
Alexey Bataev8bf6b3e2015-04-02 13:07:08 +0000105#pragma omp parallel firstprivate(t_var)
106 {}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000107 return T();
108}
109
110int main() {
Kelvin Li4eea8c62015-09-15 18:56:58 +0000111 static int sivar;
Alexey Bataev417089f2016-02-17 13:19:37 +0000112 SS ss(sivar);
Alexey Bataevf841bd92014-12-16 07:00:22 +0000113#ifdef LAMBDA
114 // LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,
115 // LAMBDA-LABEL: @main
Alexey Bataev417089f2016-02-17 13:19:37 +0000116 // LAMBDA: alloca [[SS_TY]],
117 // LAMBDA: alloca [[CAP_TY:%.+]],
118 // LAMBDA: call{{.*}} void [[OUTER_LAMBDA:@[^(]+]]([[CAP_TY]]*
Alexey Bataevf841bd92014-12-16 07:00:22 +0000119 [&]() {
120 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
Kelvin Li4eea8c62015-09-15 18:56:58 +0000121 // LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 2, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G]], {{.+}})
122#pragma omp parallel firstprivate(g, sivar)
Alexey Bataevf841bd92014-12-16 07:00:22 +0000123 {
Alexey Bataev417089f2016-02-17 13:19:37 +0000124 // LAMBDA: define {{.+}} @{{.+}}([[SS_TY]]*
125 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
126 // LAMBDA: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
127 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
128 // LAMBDA: store i8
129 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
130 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
131 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
132 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000133 // LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32, i32, i32, [4 x i{{[0-9]+}}]*)* [[SS_MICROTASK:@.+]] to void
Alexey Bataev417089f2016-02-17 13:19:37 +0000134 // LAMBDA: ret
135
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000136 // LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32 {{.+}}, i32 {{.+}}, i32 {{.+}}, [4 x i{{[0-9]+}}]* {{.+}})
Alexey Bataev417089f2016-02-17 13:19:37 +0000137 // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %
138 // LAMBDA: call{{.*}} void
139 // LAMBDA: ret void
140
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000141 // LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32 {{.+}}, i32 {{.+}}, i32 {{.+}})
Alexey Bataev417089f2016-02-17 13:19:37 +0000142 // LAMBDA: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
143 // LAMBDA: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
144 // LAMBDA: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
145 // LAMBDA: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
146 // LAMBDA: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
147 // LAMBDA-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
148 // LAMBDA-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
149 // LAMBDA-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
150 // LAMBDA-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
151 // LAMBDA-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
152 // LAMBDA-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
153 // LAMBDA-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
154 // LAMBDA-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
155 // LAMBDA-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
156 // LAMBDA-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
157 // LAMBDA-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
158 // LAMBDA-NEXT: ret void
159
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000160 // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}}, i32 {{.*}}%{{.+}})
Kelvin Li4eea8c62015-09-15 18:56:58 +0000161 // LAMBDA: [[SIVAR_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000162 // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}}, align 128
Alexey Bataev2377fe92015-09-10 08:12:02 +0000163 // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_REF_ADDR:%.+]]
Alexey Bataevc71a4092015-09-11 10:29:41 +0000164 // LAMBDA: [[G_VAL:%.+]] = load volatile i{{[0-9]+}}, i{{[0-9]+}}* [[G_REF]], align 128
165 // LAMBDA: store i{{[0-9]+}} [[G_VAL]], i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
Alexey Bataevcd8b6a22016-02-15 08:07:17 +0000166 // LAMBDA-NOT: call {{.*}}void @__kmpc_barrier(
Alexey Bataevf841bd92014-12-16 07:00:22 +0000167 g = 1;
Kelvin Li4eea8c62015-09-15 18:56:58 +0000168 sivar = 2;
Alexey Bataevb44fdfc2015-07-14 10:32:29 +0000169 // LAMBDA: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
Kelvin Li4eea8c62015-09-15 18:56:58 +0000170 // LAMBDA: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]],
David Blaikie218b7832015-02-27 19:18:17 +0000171 // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
Alexey Bataevf841bd92014-12-16 07:00:22 +0000172 // LAMBDA: store i{{[0-9]+}}* [[G_PRIVATE_ADDR]], i{{[0-9]+}}** [[G_PRIVATE_ADDR_REF]]
Kelvin Li4eea8c62015-09-15 18:56:58 +0000173 // LAMBDA: [[SIVAR_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
174 // LAMBDA: store i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]], i{{[0-9]+}}** [[SIVAR_PRIVATE_ADDR_REF]]
David Blaikieea3e51d2015-06-29 17:29:50 +0000175 // LAMBDA: call{{.*}} void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG]])
Alexey Bataevf841bd92014-12-16 07:00:22 +0000176 [&]() {
177 // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
178 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
179 g = 2;
Kelvin Li4eea8c62015-09-15 18:56:58 +0000180 sivar = 4;
David Blaikiea953f282015-02-27 21:19:58 +0000181 // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
David Blaikie218b7832015-02-27 19:18:17 +0000182 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
David Blaikiea953f282015-02-27 21:19:58 +0000183 // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_PTR_REF]]
Kelvin Li4eea8c62015-09-15 18:56:58 +0000184 // LAMBDA: [[SIVAR_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
185 // LAMBDA: [[SIVAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[SIVAR_PTR_REF]]
186 // LAMBDA: store i{{[0-9]+}} 4, i{{[0-9]+}}* [[SIVAR_REF]]
Alexey Bataevf841bd92014-12-16 07:00:22 +0000187 }();
188 }
189 }();
190 return 0;
191#elif defined(BLOCKS)
192 // BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,
193 // BLOCKS-LABEL: @main
Alexey Bataev417089f2016-02-17 13:19:37 +0000194 // BLOCKS: call
David Blaikieea3e51d2015-06-29 17:29:50 +0000195 // BLOCKS: call {{.*}}void {{%.+}}(i8
Alexey Bataevf841bd92014-12-16 07:00:22 +0000196 ^{
197 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
Kelvin Li4eea8c62015-09-15 18:56:58 +0000198 // BLOCKS: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 2, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G]], {{.+}})
199#pragma omp parallel firstprivate(g, sivar)
Alexey Bataevf841bd92014-12-16 07:00:22 +0000200 {
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000201 // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}}, i32 {{.*}}%{{.+}})
Kelvin Li4eea8c62015-09-15 18:56:58 +0000202 // BLOCKS: [[SIVAR_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000203 // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}}, align 128
Kelvin Li4eea8c62015-09-15 18:56:58 +0000204 // BLOCKS: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_REF_ADDR:%.+]]
Alexey Bataevc71a4092015-09-11 10:29:41 +0000205 // BLOCKS: [[G_VAL:%.+]] = load volatile i{{[0-9]+}}, i{{[0-9]+}}* [[G_REF]], align 128
206 // BLOCKS: store i{{[0-9]+}} [[G_VAL]], i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
Alexey Bataevcd8b6a22016-02-15 08:07:17 +0000207 // BLOCKS-NOT: call {{.*}}void @__kmpc_barrier(
Alexey Bataevf841bd92014-12-16 07:00:22 +0000208 g = 1;
Kelvin Li4eea8c62015-09-15 18:56:58 +0000209 sivar = 2;
Alexey Bataevb44fdfc2015-07-14 10:32:29 +0000210 // BLOCKS: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
Kelvin Li4eea8c62015-09-15 18:56:58 +0000211 // BLOCKS: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]],
Alexey Bataevf841bd92014-12-16 07:00:22 +0000212 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
213 // BLOCKS: i{{[0-9]+}}* [[G_PRIVATE_ADDR]]
214 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
Kelvin Li4eea8c62015-09-15 18:56:58 +0000215 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
216 // BLOCKS: i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]]
217 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
David Blaikieea3e51d2015-06-29 17:29:50 +0000218 // BLOCKS: call {{.*}}void {{%.+}}(i8
Alexey Bataevf841bd92014-12-16 07:00:22 +0000219 ^{
220 // BLOCKS: define {{.+}} void {{@.+}}(i8*
221 g = 2;
Kelvin Li4eea8c62015-09-15 18:56:58 +0000222 sivar = 4;
Alexey Bataevf841bd92014-12-16 07:00:22 +0000223 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
Alexey Bataevb44fdfc2015-07-14 10:32:29 +0000224 // BLOCKS: store i{{[0-9]+}} 2, i{{[0-9]+}}*
Alexey Bataevf841bd92014-12-16 07:00:22 +0000225 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
Kelvin Li4eea8c62015-09-15 18:56:58 +0000226 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
227 // BLOCKS: store i{{[0-9]+}} 4, i{{[0-9]+}}*
228 // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
Alexey Bataevf841bd92014-12-16 07:00:22 +0000229 // BLOCKS: ret
230 }();
231 }
232 }();
233 return 0;
Alexey Bataev417089f2016-02-17 13:19:37 +0000234// BLOCKS: define {{.+}} @{{.+}}([[SS_TY]]*
235// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
236// BLOCKS: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
237// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
238// BLOCKS: store i8
239// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
240// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
241// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
242// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000243// BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32, i32, i32, [4 x i{{[0-9]+}}]*)* [[SS_MICROTASK:@.+]] to void
Alexey Bataev417089f2016-02-17 13:19:37 +0000244// BLOCKS: ret
245
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000246// BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32 {{.+}}, i32 {{.+}}, i32 {{.+}}, [4 x i{{[0-9]+}}]* {{.+}})
Alexey Bataev417089f2016-02-17 13:19:37 +0000247// BLOCKS-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %
248// BLOCKS: call{{.*}} void
249// BLOCKS: ret void
250
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000251// BLOCKS: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32 {{.+}}, i32 {{.+}}, i32 {{.+}})
Alexey Bataev417089f2016-02-17 13:19:37 +0000252// BLOCKS: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
253// BLOCKS: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
254// BLOCKS: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
255// BLOCKS: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
256// BLOCKS: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
257// BLOCKS-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
258// BLOCKS-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
259// BLOCKS-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
260// BLOCKS-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
261// BLOCKS-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
262// BLOCKS-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
263// BLOCKS-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
264// BLOCKS-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
265// BLOCKS-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
266// BLOCKS-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
267// BLOCKS-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
268// BLOCKS-NEXT: ret void
Alexey Bataevf841bd92014-12-16 07:00:22 +0000269#else
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000270 S<float> test;
271 int t_var = 0;
272 int vec[] = {1, 2};
273 S<float> s_arr[] = {1, 2};
274 S<float> var(3);
Kelvin Li4eea8c62015-09-15 18:56:58 +0000275#pragma omp parallel firstprivate(t_var, vec, s_arr, var, sivar)
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000276 {
277 vec[0] = t_var;
278 s_arr[0] = var;
Kelvin Li4eea8c62015-09-15 18:56:58 +0000279 sivar = 2;
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000280 }
Alexey Bataeva8d4a5432015-04-02 07:48:16 +0000281#pragma omp parallel firstprivate(t_var)
282 {}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000283 return tmain<int>();
Alexey Bataevf841bd92014-12-16 07:00:22 +0000284#endif
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000285}
286
Alexey Bataevcbcb7892014-10-10 02:50:06 +0000287// CHECK: define {{.*}}i{{[0-9]+}} @main()
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000288// CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
Alexey Bataev25cdd152014-10-08 15:39:06 +0000289// CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000290// CHECK: call {{.*}}void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x i32]*, i32, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}})* [[MAIN_MICROTASK:@.+]] to void
Alexey Bataevcbcb7892014-10-10 02:50:06 +0000291// CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
Alexey Bataev25cdd152014-10-08 15:39:06 +0000292// CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000293// CHECK: ret
294//
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000295// CHECK: define internal {{.*}}void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, i32 {{.*}}%{{.+}}, [2 x [[S_FLOAT_TY]]]* dereferenceable(8) %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}}, i32 {{.*}}[[SIVAR:%.+]])
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000296// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000297// CHECK: [[SIVAR7_PRIV:%.+]] = alloca i{{[0-9]+}},
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000298// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
299// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_FLOAT_TY]]],
300// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
Alexey Bataev18095712014-10-10 12:19:54 +0000301// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
Alexey Bataev2377fe92015-09-10 08:12:02 +0000302
303// CHECK: [[VEC_REF:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** %
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000304// CHECK-NOT: load i{{[0-9]+}}*, i{{[0-9]+}}** %
Alexey Bataev2377fe92015-09-10 08:12:02 +0000305// CHECK: [[S_ARR_REF:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x [[S_FLOAT_TY]]]** %
306// CHECK: [[VAR_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000307// CHECK-NOT: load i{{[0-9]+}}*, i{{[0-9]+}}** %
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000308// CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
309// CHECK: [[VEC_SRC:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_REF]] to i8*
Pete Cooper3b39e882015-11-19 05:55:59 +0000310// CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* [[VEC_SRC]],
David Blaikie218b7832015-02-27 19:18:17 +0000311// CHECK: [[S_ARR_PRIV_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* [[S_ARR_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
Alexey Bataev420d45b2015-04-14 05:11:24 +0000312// CHECK: [[S_ARR_BEGIN:%.+]] = bitcast [2 x [[S_FLOAT_TY]]]* [[S_ARR_REF]] to [[S_FLOAT_TY]]*
David Blaikie218b7832015-02-27 19:18:17 +0000313// CHECK: [[S_ARR_PRIV_END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[S_ARR_PRIV_BEGIN]], i{{[0-9]+}} 2
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000314// CHECK: [[IS_EMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[S_ARR_PRIV_BEGIN]], [[S_ARR_PRIV_END]]
315// CHECK: br i1 [[IS_EMPTY]], label %[[S_ARR_BODY_DONE:.+]], label %[[S_ARR_BODY:.+]]
316// CHECK: [[S_ARR_BODY]]
Alexey Bataev25cdd152014-10-08 15:39:06 +0000317// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR:@.+]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
318// CHECK: call {{.*}} [[S_FLOAT_TY_COPY_CONSTR:@.+]]([[S_FLOAT_TY]]* {{.+}}, [[S_FLOAT_TY]]* {{.+}}, [[ST_TY]]* [[ST_TY_TEMP]])
319// CHECK: call {{.*}} [[ST_TY_DESTR:@.+]]([[ST_TY]]* [[ST_TY_TEMP]])
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000320// CHECK: br i1 {{.+}}, label %{{.+}}, label %[[S_ARR_BODY]]
Alexey Bataev25cdd152014-10-08 15:39:06 +0000321// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
322// CHECK: call {{.*}} [[S_FLOAT_TY_COPY_CONSTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]], [[S_FLOAT_TY]]* {{.*}} [[VAR_REF]], [[ST_TY]]* [[ST_TY_TEMP]])
323// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
Kelvin Li4eea8c62015-09-15 18:56:58 +0000324
Kelvin Li4eea8c62015-09-15 18:56:58 +0000325// CHECK: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[SIVAR7_PRIV]],
326
Alexey Bataev25cdd152014-10-08 15:39:06 +0000327// CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
328// CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000329// CHECK: ret void
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000330// CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
331// CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
Alexey Bataev25cdd152014-10-08 15:39:06 +0000332// CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
Alexey Bataev2377fe92015-09-10 08:12:02 +0000333// CHECK: call {{.*}}void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x i32]*, i32*, [2 x [[S_INT_TY]]]*, [[S_INT_TY]]*)* [[TMAIN_MICROTASK:@.+]] to void
Alexey Bataev25cdd152014-10-08 15:39:06 +0000334// CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000335// CHECK: ret
336//
Alexey Bataeva462b452016-02-17 15:36:39 +0000337// CHECK: define {{.+}} @{{.+}}([[SS_TY]]*
Alexey Bataev417089f2016-02-17 13:19:37 +0000338// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
339// CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
340// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
341// CHECK: store i8
342// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
343// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
344// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
345// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000346// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32, i32, i32, [4 x i32]*)* [[SS_MICROTASK:@.+]] to void
Alexey Bataev417089f2016-02-17 13:19:37 +0000347// CHECK: ret
348
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000349// CHECK: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32 {{.+}}, i32 {{.+}}, i32 {{.+}}, [4 x i{{[0-9]+}}]* {{.+}})
Alexey Bataev417089f2016-02-17 13:19:37 +0000350// CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
351// CHECK: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
352// CHECK: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
Alexey Bataevfeddd642016-04-22 09:05:03 +0000353// CHECK: [[E_PRIV:%.+]] = alloca [4 x i{{[0-9]+}}],
Alexey Bataev417089f2016-02-17 13:19:37 +0000354// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[A_PRIV]]
Alexey Bataev417089f2016-02-17 13:19:37 +0000355// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[B_PRIV]]
356// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[C_PRIV]]
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000357// CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
Alexey Bataev417089f2016-02-17 13:19:37 +0000358// CHECK: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
Alexey Bataevfeddd642016-04-22 09:05:03 +0000359// CHECK: bitcast [4 x i{{[0-9]+}}]* [[E_PRIV]] to i8*
360// CHECK: bitcast [4 x i{{[0-9]+}}]* %{{.+}} to i8*
361// CHECK: call void @llvm.memcpy
362// CHECK: store [4 x i{{[0-9]+}}]* [[E_PRIV]], [4 x i{{[0-9]+}}]** [[REFE:%.+]],
Alexey Bataev417089f2016-02-17 13:19:37 +0000363// CHECK-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
364// CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
365// CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
366// CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
367// CHECK-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
368// CHECK-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
369// CHECK-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
370// CHECK-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
371// CHECK-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
372// CHECK-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
373// CHECK-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
Alexey Bataevfeddd642016-04-22 09:05:03 +0000374// CHECK-NEXT: [[E_PRIV:%.+]] = load [4 x i{{[0-9]+}}]*, [4 x i{{[0-9]+}}]** [[REFE]],
375// CHECK-NEXT: [[E_PRIV_2:%.+]] = getelementptr inbounds [4 x i{{[0-9]+}}], [4 x i{{[0-9]+}}]* [[E_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
376// CHECK-NEXT: store i32 1111, i32* [[E_PRIV_2]],
Alexey Bataev417089f2016-02-17 13:19:37 +0000377// CHECK-NEXT: ret void
378
Alexey Bataev2377fe92015-09-10 08:12:02 +0000379// CHECK: define internal {{.*}}void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, i32* dereferenceable(4) %{{.+}}, [2 x [[S_INT_TY]]]* dereferenceable(8) %{{.+}}, [[S_INT_TY]]* dereferenceable(4) %{{.+}})
Alexey Bataev1d7f0fa2015-09-10 09:48:30 +0000380// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}}, align 128
381// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}], align 128
382// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]], align 128
383// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]], align 128
Alexey Bataev18095712014-10-10 12:19:54 +0000384// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
Alexey Bataev2377fe92015-09-10 08:12:02 +0000385
386// CHECK: [[VEC_REF:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** %
387// CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
388// CHECK: [[S_ARR_REF:%.+]] = load [2 x [[S_INT_TY]]]*, [2 x [[S_INT_TY]]]** %
389// CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
390
Alexey Bataevc71a4092015-09-11 10:29:41 +0000391// CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_REF]], align 128
392// CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_PRIV]], align 128
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000393// CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
394// CHECK: [[VEC_SRC:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_REF]] to i8*
Pete Cooper3b39e882015-11-19 05:55:59 +0000395// CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* [[VEC_SRC]], i{{[0-9]+}} {{[0-9]+}}, i{{[0-9]+}} 128,
David Blaikie218b7832015-02-27 19:18:17 +0000396// CHECK: [[S_ARR_PRIV_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_INT_TY]]], [2 x [[S_INT_TY]]]* [[S_ARR_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
Alexey Bataev420d45b2015-04-14 05:11:24 +0000397// CHECK: [[S_ARR_BEGIN:%.+]] = bitcast [2 x [[S_INT_TY]]]* [[S_ARR_REF]] to [[S_INT_TY]]*
David Blaikie218b7832015-02-27 19:18:17 +0000398// CHECK: [[S_ARR_PRIV_END:%.+]] = getelementptr [[S_INT_TY]], [[S_INT_TY]]* [[S_ARR_PRIV_BEGIN]], i{{[0-9]+}} 2
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000399// CHECK: [[IS_EMPTY:%.+]] = icmp eq [[S_INT_TY]]* [[S_ARR_PRIV_BEGIN]], [[S_ARR_PRIV_END]]
400// CHECK: br i1 [[IS_EMPTY]], label %[[S_ARR_BODY_DONE:.+]], label %[[S_ARR_BODY:.+]]
401// CHECK: [[S_ARR_BODY]]
Alexey Bataev25cdd152014-10-08 15:39:06 +0000402// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
403// CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR:@.+]]([[S_INT_TY]]* {{.+}}, [[S_INT_TY]]* {{.+}}, [[ST_TY]]* [[ST_TY_TEMP]])
404// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000405// CHECK: br i1 {{.+}}, label %{{.+}}, label %[[S_ARR_BODY]]
Alexey Bataev25cdd152014-10-08 15:39:06 +0000406// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
407// CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR]]([[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]* {{.*}} [[VAR_REF]], [[ST_TY]]* [[ST_TY_TEMP]])
408// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
Alexey Bataevcd8b6a22016-02-15 08:07:17 +0000409// CHECK-NOT: call {{.*}}void @__kmpc_barrier(
Alexey Bataev25cdd152014-10-08 15:39:06 +0000410// CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
411// CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]*
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000412// CHECK: ret void
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000413
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000414#endif
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000415#else
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000416struct St {
417 int a, b;
418 St() : a(0), b(0) {}
419 St(const St &) { }
420 ~St() {}
Alexey Bataev2377fe92015-09-10 08:12:02 +0000421 void St_func(St s[2], int n, long double vla1[n]) {
Alexey Bataevc71a4092015-09-11 10:29:41 +0000422 double vla2[n][n] __attribute__((aligned(128)));
Alexey Bataev2377fe92015-09-10 08:12:02 +0000423 a = b;
424#pragma omp parallel firstprivate(s, vla1, vla2)
425 vla1[b] = vla2[1][n - 1] = a = b;
426 }
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000427};
428
Alexey Bataev2377fe92015-09-10 08:12:02 +0000429// ARRAY-LABEL: array_func
Alexey Bataev5129d3a2015-05-21 09:47:46 +0000430void array_func(float a[3], St s[2], int n, long double vla1[n]) {
Alexey Bataevc71a4092015-09-11 10:29:41 +0000431 double vla2[n][n] __attribute__((aligned(128)));
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000432// ARRAY: @__kmpc_fork_call(
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000433// ARRAY-DAG: [[PRIV_S:%.+]] = alloca %struct.St*,
434// ARRAY-DAG: [[PRIV_VLA1:%.+]] = alloca x86_fp80*,
435// ARRAY-DAG: [[PRIV_A:%.+]] = alloca float*,
Alexey Bataev2377fe92015-09-10 08:12:02 +0000436// ARRAY-DAG: [[PRIV_VLA2:%.+]] = alloca double*,
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000437// ARRAY-DAG: store %struct.St* %{{.+}}, %struct.St** [[PRIV_S]],
438// ARRAY-DAG: store x86_fp80* %{{.+}}, x86_fp80** [[PRIV_VLA1]],
439// ARRAY-DAG: store float* %{{.+}}, float** [[PRIV_A]],
Alexey Bataev2377fe92015-09-10 08:12:02 +0000440// ARRAY-DAG: store double* %{{.+}}, double** [[PRIV_VLA2]],
Alexey Bataev16dc7b62015-05-20 03:46:04 +0000441// ARRAY: call i8* @llvm.stacksave()
Alexey Bataev16dc7b62015-05-20 03:46:04 +0000442// ARRAY: [[SIZE:%.+]] = mul nuw i64 %{{.+}}, 8
Pete Cooper3b39e882015-11-19 05:55:59 +0000443// ARRAY: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.+}}, i8* %{{.+}}, i64 [[SIZE]], i32 128, i1 false)
Alexey Bataev16dc7b62015-05-20 03:46:04 +0000444#pragma omp parallel firstprivate(a, s, vla1, vla2)
Alexey Bataev2377fe92015-09-10 08:12:02 +0000445 s[0].St_func(s, n, vla1);
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000446 ;
447}
Alexey Bataev2377fe92015-09-10 08:12:02 +0000448
449// ARRAY-LABEL: St_func
450// ARRAY: @__kmpc_fork_call(
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000451// ARRAY-DAG: [[PRIV_VLA1:%.+]] = alloca x86_fp80*,
452// ARRAY-DAG: [[PRIV_S:%.+]] = alloca %struct.St*,
Alexey Bataev2377fe92015-09-10 08:12:02 +0000453// ARRAY-DAG: [[PRIV_VLA2:%.+]] = alloca double*,
Alexey Bataev7ace49d2016-05-17 08:55:33 +0000454// ARRAY-DAG: store %struct.St* %{{.+}}, %struct.St** [[PRIV_S]],
455// ARRAY-DAG: store x86_fp80* %{{.+}}, x86_fp80** [[PRIV_VLA1]],
Alexey Bataev2377fe92015-09-10 08:12:02 +0000456// ARRAY-DAG: store double* %{{.+}}, double** [[PRIV_VLA2]],
457// ARRAY: call i8* @llvm.stacksave()
458// ARRAY: [[SIZE:%.+]] = mul nuw i64 %{{.+}}, 8
Pete Cooper3b39e882015-11-19 05:55:59 +0000459// ARRAY: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.+}}, i8* %{{.+}}, i64 [[SIZE]], i32 128, i1 false)
Alexey Bataev1d9c15c2015-05-19 12:31:28 +0000460#endif
461
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000462