1 // RUN: %clang_cc1 -verify -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 %s -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -verify -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 -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
6 // expected-no-diagnostics
7 // REQUIRES: x86-registered-target
8 #ifndef HEADER
9 #define HEADER
10
11 template <class T>
12 struct S {
13 T f;
SS14 S(T a) : f(a) {}
SS15 S() : f() {}
16 S<T> &operator=(const S<T> &);
operator TS17 operator T() { return T(); }
~SS18 ~S() {}
19 };
20
21 volatile int g = 1212;
22 volatile int &g1 = g;
23 float f;
24 char cnt;
25
26 struct SS {
27 int a;
28 int b : 4;
29 int &c;
SSSS30 SS(int &d) : a(0), b(0), c(d) {
31 #pragma omp parallel
32 #pragma omp for linear(a, b, c)
33 for (int i = 0; i < 2; ++i)
34 #ifdef LAMBDA
35 [&]() {
36 ++this->a, --b, (this)->c /= 1;
37 #pragma omp parallel
38 #pragma omp for linear(a, b) linear(ref(c))
39 for (int i = 0; i < 2; ++i)
40 ++(this)->a, --b, this->c /= 1;
41 }();
42 #elif defined(BLOCKS)
43 ^{
44 ++a;
45 --this->b;
46 (this)->c /= 1;
47 #pragma omp parallel
48 #pragma omp for linear(a, b) linear(uval(c))
49 for (int i = 0; i < 2; ++i)
50 ++(this)->a, --b, this->c /= 1;
51 }();
52 #else
53 ++this->a, --b, c /= 1;
54 #endif
55 }
56 };
57
58 template <typename T>
59 struct SST {
60 T a;
SSTSST61 SST() : a(T()) {
62 #pragma omp parallel
63 #pragma omp for linear(a)
64 for (int i = 0; i < 2; ++i)
65 #ifdef LAMBDA
66 [&]() {
67 [&]() {
68 ++this->a;
69 #pragma omp parallel
70 #pragma omp for linear(a)
71 for (int i = 0; i < 2; ++i)
72 ++(this)->a;
73 }();
74 }();
75 #elif defined(BLOCKS)
76 ^{
77 ^{
78 ++a;
79 #pragma omp parallel
80 #pragma omp for linear(a)
81 for (int i = 0; i < 2; ++i)
82 ++(this)->a;
83 }();
84 }();
85 #else
86 ++(this)->a;
87 #endif
88 }
89 };
90
91 // CHECK: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
92 // LAMBDA: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
93 // BLOCKS: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
94 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
95 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
96 // CHECK-DAG: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8*
97 // CHECK-DAG: [[F:@.+]] = global float 0.0
98 // CHECK-DAG: [[CNT:@.+]] = global i8 0
99 template <typename T>
tmain()100 T tmain() {
101 S<T> test;
102 SST<T> sst;
103 T *pvar = &test.f;
104 T &lvar = test.f;
105 #pragma omp parallel
106 #pragma omp for linear(pvar, lvar)
107 for (int i = 0; i < 2; ++i) {
108 ++pvar, ++lvar;
109 }
110 return T();
111 }
112
main()113 int main() {
114 static int sivar;
115 SS ss(sivar);
116 #ifdef LAMBDA
117 // LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,
118 // LAMBDA-LABEL: @main
119 // LAMBDA: alloca [[SS_TY]],
120 // LAMBDA: alloca [[CAP_TY:%.+]],
121 // LAMBDA: call void [[OUTER_LAMBDA:@.+]]([[CAP_TY]]*
122 [&]() {
123 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
124 // LAMBDA: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
125 #pragma omp parallel
126 #pragma omp for linear(g, g1:5)
127 for (int i = 0; i < 2; ++i) {
128 // LAMBDA: define {{.+}} @{{.+}}([[SS_TY]]*
129 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
130 // LAMBDA: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
131 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
132 // LAMBDA: store i8
133 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
134 // LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void
135 // LAMBDA: ret
136
137 // LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})
138 // LAMBDA: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 0
139 // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
140 // LAMBDA: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 2
141 // LAMBDA: call void @__kmpc_for_static_init_4(
142 // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]*
143 // LAMBDA: call{{.*}} void
144 // LAMBDA: call void @__kmpc_for_static_fini(
145 // LAMBDA: br i1
146 // LAMBDA: [[B_REF:%.+]] = getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
147 // LAMBDA: store i8 %{{.+}}, i8* [[B_REF]],
148 // LAMBDA: br label
149 // LAMBDA: ret void
150
151 // LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
152 // LAMBDA: alloca i{{[0-9]+}},
153 // LAMBDA: alloca i{{[0-9]+}},
154 // LAMBDA: alloca i{{[0-9]+}},
155 // LAMBDA: alloca i{{[0-9]+}},
156 // LAMBDA: alloca i{{[0-9]+}},
157 // LAMBDA: alloca i{{[0-9]+}},
158 // LAMBDA: alloca i{{[0-9]+}},
159 // LAMBDA: alloca i{{[0-9]+}},
160 // LAMBDA: alloca i{{[0-9]+}},
161 // LAMBDA: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
162 // LAMBDA: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
163 // LAMBDA: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
164 // LAMBDA: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
165 // LAMBDA: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
166 // LAMBDA: call void @__kmpc_for_static_init_4(
167 // LAMBDA: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
168 // LAMBDA-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
169 // LAMBDA-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
170 // LAMBDA-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
171 // LAMBDA-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
172 // LAMBDA-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
173 // LAMBDA-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
174 // LAMBDA-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
175 // LAMBDA-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
176 // LAMBDA-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
177 // LAMBDA-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
178 // LAMBDA: call void @__kmpc_for_static_fini(
179 // LAMBDA: br i1
180 // LAMBDA: br label
181 // LAMBDA: ret void
182
183 // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
184 // LAMBDA: alloca i{{[0-9]+}},
185 // LAMBDA: [[G_START_ADDR:%.+]] = alloca i{{[0-9]+}},
186 // LAMBDA: alloca i{{[0-9]+}},
187 // LAMBDA: alloca i{{[0-9]+}},
188 // LAMBDA: alloca i{{[0-9]+}},
189 // LAMBDA: alloca i{{[0-9]+}},
190 // LAMBDA: alloca i{{[0-9]+}},
191 // LAMBDA: alloca i{{[0-9]+}},
192 // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
193 // LAMBDA: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %{{.+}}
194 // LAMBDA: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
195 // LAMBDA: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
196 // LAMBDA: [[VAL:%.+]] = load i32, i32* [[G_START_ADDR]]
197 // LAMBDA: [[CNT:%.+]] = load i32, i32*
198 // LAMBDA: [[MUL:%.+]] = mul nsw i32 [[CNT]], 5
199 // LAMBDA: [[ADD:%.+]] = add nsw i32 [[VAL]], [[MUL]]
200 // LAMBDA: store i32 [[ADD]], i32* [[G_PRIVATE_ADDR]],
201 // LAMBDA: [[VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]],
202 // LAMBDA: [[ADD:%.+]] = add nsw i32 [[VAL]], 5
203 // LAMBDA: store i32 [[ADD]], i32* [[G_PRIVATE_ADDR]],
204 // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
205 // LAMBDA: store i{{[0-9]+}}* [[G_PRIVATE_ADDR]], i{{[0-9]+}}** [[G_PRIVATE_ADDR_REF]]
206 // LAMBDA: call void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG]])
207 // LAMBDA: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]])
208 g += 5;
209 g1 += 5;
210 // LAMBDA: call void @__kmpc_barrier(%{{.+}}* @{{.+}}, i{{[0-9]+}} [[GTID]])
211 [&]() {
212 // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
213 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
214 g = 2;
215 g1 = 2;
216 // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
217 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
218 // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_PTR_REF]]
219 // LAMBDA: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[G_REF]]
220 }();
221 }
222 }();
223 return 0;
224 #elif defined(BLOCKS)
225 // BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,
226 // BLOCKS-LABEL: @main
227 // BLOCKS: call
228 // BLOCKS: call void {{%.+}}(i8
229 ^{
230 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
231 // BLOCKS: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
232 #pragma omp parallel
233 #pragma omp for linear(g, g1:5)
234 for (int i = 0; i < 2; ++i) {
235 // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
236 // BLOCKS: alloca i{{[0-9]+}},
237 // BLOCKS: [[G_START_ADDR:%.+]] = alloca i{{[0-9]+}},
238 // BLOCKS: alloca i{{[0-9]+}},
239 // BLOCKS: alloca i{{[0-9]+}},
240 // BLOCKS: alloca i{{[0-9]+}},
241 // BLOCKS: alloca i{{[0-9]+}},
242 // BLOCKS: alloca i{{[0-9]+}},
243 // BLOCKS: alloca i{{[0-9]+}},
244 // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
245 // BLOCKS: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %{{.+}}
246 // BLOCKS: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
247 // BLOCKS: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
248 // BLOCKS: [[VAL:%.+]] = load i32, i32* [[G_START_ADDR]]
249 // BLOCKS: [[CNT:%.+]] = load i32, i32*
250 // BLOCKS: [[MUL:%.+]] = mul nsw i32 [[CNT]], 5
251 // BLOCKS: [[ADD:%.+]] = add nsw i32 [[VAL]], [[MUL]]
252 // BLOCKS: store i32 [[ADD]], i32* [[G_PRIVATE_ADDR]],
253 // BLOCKS: [[VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]],
254 // BLOCKS: [[ADD:%.+]] = add nsw i32 [[VAL]], 5
255 // BLOCKS: store i32 [[ADD]], i32* [[G_PRIVATE_ADDR]],
256 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
257 // BLOCKS: i{{[0-9]+}}* [[G_PRIVATE_ADDR]]
258 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
259 // BLOCKS: call void {{%.+}}(i8
260 // BLOCKS: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]])
261 g += 5;
262 g1 += 5;
263 // BLOCKS: call void @__kmpc_barrier(%{{.+}}* @{{.+}}, i{{[0-9]+}} [[GTID]])
264 g = 1;
265 g1 = 5;
266 ^{
267 // BLOCKS: define {{.+}} void {{@.+}}(i8*
268 g = 2;
269 g1 = 2;
270 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
271 // BLOCKS: store i{{[0-9]+}} 2, i{{[0-9]+}}*
272 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
273 // BLOCKS: ret
274 }();
275 }
276 }();
277 return 0;
278 // BLOCKS: define {{.+}} @{{.+}}([[SS_TY]]*
279 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
280 // BLOCKS: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
281 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
282 // BLOCKS: store i8
283 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
284 // BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void
285 // BLOCKS: ret
286
287 // BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})
288 // BLOCKS: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 0
289 // BLOCKS-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
290 // BLOCKS: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 2
291 // BLOCKS: call void @__kmpc_for_static_init_4(
292 // BLOCKS-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]*
293 // BLOCKS: call{{.*}} void
294 // BLOCKS: call void @__kmpc_for_static_fini(
295 // BLOCKS: br i1
296 // BLOCKS: [[B_REF:%.+]] = getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
297 // BLOCKS: store i8 %{{.+}}, i8* [[B_REF]],
298 // BLOCKS: br label
299 // BLOCKS: ret void
300
301 // BLOCKS: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
302 // BLOCKS: alloca i{{[0-9]+}},
303 // BLOCKS: alloca i{{[0-9]+}},
304 // BLOCKS: alloca i{{[0-9]+}},
305 // BLOCKS: alloca i{{[0-9]+}},
306 // BLOCKS: alloca i{{[0-9]+}},
307 // BLOCKS: alloca i{{[0-9]+}},
308 // BLOCKS: alloca i{{[0-9]+}},
309 // BLOCKS: alloca i{{[0-9]+}},
310 // BLOCKS: alloca i{{[0-9]+}},
311 // BLOCKS: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
312 // BLOCKS: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
313 // BLOCKS: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
314 // BLOCKS: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
315 // BLOCKS: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
316 // BLOCKS: call void @__kmpc_for_static_init_4(
317 // BLOCKS: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
318 // BLOCKS-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
319 // BLOCKS-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
320 // BLOCKS-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
321 // BLOCKS-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
322 // BLOCKS-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
323 // BLOCKS-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
324 // BLOCKS-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
325 // BLOCKS-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
326 // BLOCKS-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
327 // BLOCKS-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
328 // BLOCKS: call void @__kmpc_for_static_fini(
329 // BLOCKS: br i1
330 // BLOCKS: br label
331 // BLOCKS: ret void
332 #else
333 S<float> test;
334 float *pvar = &test.f;
335 long long lvar = 0;
336 #pragma omp parallel
337 #pragma omp for linear(pvar, lvar : 3)
338 for (int i = 0; i < 2; ++i) {
339 pvar += 3, lvar += 3;
340 }
341 return tmain<int>();
342 #endif
343 }
344
345 // CHECK: define i{{[0-9]+}} @main()
346 // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
347 // CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
348 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 2, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, float**, i64*)* [[MAIN_MICROTASK:@.+]] to void
349 // CHECK: = call {{.+}} [[TMAIN_INT:@.+]]()
350 // CHECK: call void [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
351 // CHECK: ret
352
353 // CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, float** dereferenceable(8) %{{.+}}, i64* dereferenceable(8) %{{.+}})
354 // CHECK: alloca i{{[0-9]+}},
355 // CHECK: [[PVAR_START:%.+]] = alloca float*,
356 // CHECK: [[LVAR_START:%.+]] = alloca i64,
357 // CHECK: alloca i{{[0-9]+}},
358 // CHECK: alloca i{{[0-9]+}},
359 // CHECK: alloca i{{[0-9]+}},
360 // CHECK: alloca i{{[0-9]+}},
361 // CHECK: alloca i{{[0-9]+}},
362 // CHECK: [[PVAR_PRIV:%.+]] = alloca float*,
363 // CHECK: [[LVAR_PRIV:%.+]] = alloca i64,
364 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
365
366 // Check for default initialization.
367 // CHECK: [[PVAR_REF:%.+]] = load float**, float*** %
368 // CHECK: [[LVAR_REF:%.+]] = load i64*, i64** %
369 // CHECK: [[PVAR_VAL:%.+]] = load float*, float** [[PVAR_REF]],
370 // CHECK: store float* [[PVAR_VAL]], float** [[PVAR_START]],
371 // CHECK: [[LVAR_VAL:%.+]] = load i64, i64* [[LVAR_REF]],
372 // CHECK: store i64 [[LVAR_VAL]], i64* [[LVAR_START]],
373 // CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID:%.+]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
374 // CHECK: [[PVAR_VAL:%.+]] = load float*, float** [[PVAR_START]],
375 // CHECK: [[CNT:%.+]] = load i32, i32*
376 // CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT]], 3
377 // CHECK: [[IDX:%.+]] = sext i32 [[MUL]] to i64
378 // CHECK: [[PTR:%.+]] = getelementptr inbounds float, float* [[PVAR_VAL]], i64 [[IDX]]
379 // CHECK: store float* [[PTR]], float** [[PVAR_PRIV]],
380 // CHECK: [[LVAR_VAL:%.+]] = load i64, i64* [[LVAR_START]],
381 // CHECK: [[CNT:%.+]] = load i32, i32*
382 // CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT]], 3
383 // CHECK: [[CONV:%.+]] = sext i32 [[MUL]] to i64
384 // CHECK: [[VAL:%.+]] = add nsw i64 [[LVAR_VAL]], [[CONV]]
385 // CHECK: store i64 [[VAL]], i64* [[LVAR_PRIV]],
386 // CHECK: [[PVAR_VAL:%.+]] = load float*, float** [[PVAR_PRIV]]
387 // CHECK: [[PTR:%.+]] = getelementptr inbounds float, float* [[PVAR_VAL]], i64 3
388 // CHECK: store float* [[PTR]], float** [[PVAR_PRIV]],
389 // CHECK: [[LVAR_VAL:%.+]] = load i64, i64* [[LVAR_PRIV]],
390 // CHECK: [[ADD:%.+]] = add nsw i64 [[LVAR_VAL]], 3
391 // CHECK: store i64 [[ADD]], i64* [[LVAR_PRIV]],
392 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 %{{.+}})
393 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
394 // CHECK: ret void
395
396 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
397 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
398 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
399 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 2, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i32**, i32*)* [[TMAIN_MICROTASK:@.+]] to void
400 // CHECK: call void [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
401 // CHECK: ret
402
403 // CHECK: define {{.+}} @{{.+}}([[SS_TY]]*
404 // CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
405 // CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
406 // CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
407 // CHECK: store i8
408 // CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
409 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void
410 // CHECK: ret
411
412 // CHECK: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})
413 // CHECK: alloca i{{[0-9]+}},
414 // CHECK: alloca i{{[0-9]+}},
415 // CHECK: alloca i{{[0-9]+}},
416 // CHECK: alloca i{{[0-9]+}},
417 // CHECK: alloca i{{[0-9]+}},
418 // CHECK: alloca i{{[0-9]+}},
419 // CHECK: alloca i{{[0-9]+}},
420 // CHECK: alloca i{{[0-9]+}},
421 // CHECK: alloca i{{[0-9]+}},
422 // CHECK: alloca i{{[0-9]+}},
423 // CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
424 // CHECK: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
425 // CHECK: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
426 // CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
427 // CHECK: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
428 // CHECK: call void @__kmpc_for_static_init_4(
429 // CHECK: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
430 // CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
431 // CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
432 // CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
433 // CHECK-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
434 // CHECK-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
435 // CHECK-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
436 // CHECK-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
437 // CHECK-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
438 // CHECK-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
439 // CHECK-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
440 // CHECK: call void @__kmpc_for_static_fini(
441 // CHECK: br i1
442 // CHECK: [[B_REF:%.+]] = getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
443 // CHECK: store i8 %{{.+}}, i8* [[B_REF]],
444 // CHECK: br label
445 // CHECK: ret void
446
447 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i32** dereferenceable(8) %{{.+}}, i32* dereferenceable(4) %{{.+}})
448 // CHECK: alloca i{{[0-9]+}},
449 // CHECK: [[PVAR_START:%.+]] = alloca i32*,
450 // CHECK: [[LVAR_START:%.+]] = alloca i32,
451 // CHECK: alloca i{{[0-9]+}},
452 // CHECK: alloca i{{[0-9]+}},
453 // CHECK: alloca i{{[0-9]+}},
454 // CHECK: alloca i{{[0-9]+}},
455 // CHECK: alloca i{{[0-9]+}},
456 // CHECK: [[PVAR_PRIV:%.+]] = alloca i32*,
457 // CHECK: [[LVAR_PRIV:%.+]] = alloca i32,
458 // CHECK: [[LVAR_PRIV_REF:%.+]] = alloca i32*,
459 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
460
461 // Check for default initialization.
462 // CHECK: [[PVAR_REF:%.+]] = load i32**, i32*** %
463 // CHECK: [[PVAR_VAL:%.+]] = load i32*, i32** [[PVAR_REF]],
464 // CHECK: store i32* [[PVAR_VAL]], i32** [[PVAR_START]],
465 // CHECK: [[LVAR_REF:%.+]] = load i32*, i32** %
466 // CHECK: [[LVAR_VAL:%.+]] = load i32, i32* [[LVAR_REF]],
467 // CHECK: store i32 [[LVAR_VAL]], i32* [[LVAR_START]],
468 // CHECK: store i32* [[LVAR_PRIV]], i32** [[LVAR_PRIV_REF]],
469
470 // CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID:%.+]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
471 // CHECK: [[PVAR_VAL:%.+]] = load i32*, i32** [[PVAR_START]],
472 // CHECK: [[CNT:%.+]] = load i32, i32*
473 // CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT]], 1
474 // CHECK: [[IDX:%.+]] = sext i32 [[MUL]] to i64
475 // CHECK: [[PTR:%.+]] = getelementptr inbounds i32, i32* [[PVAR_VAL]], i64 [[IDX]]
476 // CHECK: store i32* [[PTR]], i32** [[PVAR_PRIV]],
477 // CHECK: [[LVAR_VAL:%.+]] = load i32, i32* [[LVAR_START]],
478 // CHECK: [[CNT:%.+]] = load i32, i32*
479 // CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT]], 1
480 // CHECK: [[VAL:%.+]] = add nsw i32 [[LVAR_VAL]], [[MUL]]
481 // CHECK: store i32 [[VAL]], i32* [[LVAR_PRIV]],
482 // CHECK: [[PVAR_VAL:%.+]] = load i32*, i32** [[PVAR_PRIV]]
483 // CHECK: [[PTR:%.+]] = getelementptr inbounds i32, i32* [[PVAR_VAL]], i32 1
484 // CHECK: store i32* [[PTR]], i32** [[PVAR_PRIV]],
485 // CHECK: [[LVAR_PRIV:%.+]] = load i32*, i32** [[LVAR_PRIV_REF]],
486 // CHECK: [[LVAR_VAL:%.+]] = load i32, i32* [[LVAR_PRIV]],
487 // CHECK: [[ADD:%.+]] = add nsw i32 [[LVAR_VAL]], 1
488 // CHECK: store i32 [[ADD]], i32* [[LVAR_PRIV]],
489 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 %{{.+}})
490 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
491 // CHECK: ret void
492 #endif
493
494