target_data_use_device_ptr_codegen.cpp
24.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
// expected-no-diagnostics
#ifndef HEADER
#define HEADER
///==========================================================================///
// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
#ifdef CK1
double *g;
// CK1: @g = global double*
// CK1: [[MTYPE00:@.+]] = {{.*}}constant [2 x i64] [i64 51, i64 96]
// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE03:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE04:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE05:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE06:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE07:@.+]] = {{.*}}constant [1 x i64] [i64 99]
// CK1: [[MTYPE08:@.+]] = {{.*}}constant [2 x i64] [i64 99, i64 35]
// CK1: [[MTYPE09:@.+]] = {{.*}}constant [2 x i64] [i64 99, i64 99]
// CK1: [[MTYPE10:@.+]] = {{.*}}constant [2 x i64] [i64 99, i64 99]
// CK1: [[MTYPE11:@.+]] = {{.*}}constant [2 x i64] [i64 35, i64 96]
// CK1: [[MTYPE12:@.+]] = {{.*}}constant [2 x i64] [i64 35, i64 96]
// CK1-LABEL: @_Z3foo
template<typename T>
void foo(float *&lr, T *&tr) {
float *l;
T *t;
// CK1: [[T:%.+]] = load double*, double** [[DECL:@g]],
// CK1: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 1
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to double**
// CK1: store double* [[T]], double** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
// CK1: [[VAL:%.+]] = load double*, double** [[CBP]],
// CK1-NOT: store double* [[VAL]], double** [[DECL]],
// CK1: store double* [[VAL]], double** [[PVT:%.+]],
// CK1: [[TT:%.+]] = load double*, double** [[PVT]],
// CK1: getelementptr inbounds double, double* [[TT]], i32 1
#pragma omp target data map(g[:10]) use_device_ptr(g)
{
++g;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
// CK1: [[TTT:%.+]] = load double*, double** [[DECL]],
// CK1: getelementptr inbounds double, double* [[TTT]], i32 1
++g;
// CK1: [[T1:%.+]] = load float*, float** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
// CK1: store float* [[T1]], float** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE01]]
// CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
// CK1-NOT: store float* [[VAL]], float** [[DECL]],
// CK1: store float* [[VAL]], float** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
// CK1: getelementptr inbounds float, float* [[TT1]], i32 1
#pragma omp target data map(l[:10]) use_device_ptr(l)
{
++l;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE01]]
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
++l;
// CK1-NOT: call void @__tgt_target
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
#pragma omp target data map(l[:10]) use_device_ptr(l) if(0)
{
++l;
}
// CK1-NOT: call void @__tgt_target
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
++l;
// CK1: [[T1:%.+]] = load float*, float** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
// CK1: store float* [[T1]], float** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE03]]
// CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
// CK1-NOT: store float* [[VAL]], float** [[DECL]],
// CK1: store float* [[VAL]], float** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
// CK1: getelementptr inbounds float, float* [[TT1]], i32 1
#pragma omp target data map(l[:10]) use_device_ptr(l) if(1)
{
++l;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE03]]
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
++l;
// CK1: [[CMP:%.+]] = icmp ne float* %{{.+}}, null
// CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]
// CK1: [[BTHEN]]:
// CK1: [[T1:%.+]] = load float*, float** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
// CK1: store float* [[T1]], float** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE04]]
// CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
// CK1-NOT: store float* [[VAL]], float** [[DECL]],
// CK1: store float* [[VAL]], float** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
// CK1: getelementptr inbounds float, float* [[TT1]], i32 1
// CK1: br label %[[BEND:.+]]
// CK1: [[BELSE]]:
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
// CK1: br label %[[BEND]]
#pragma omp target data map(l[:10]) use_device_ptr(l) if(lr != 0)
{
++l;
}
// CK1: [[BEND]]:
// CK1: [[CMP:%.+]] = icmp ne float* %{{.+}}, null
// CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]
// CK1: [[BTHEN]]:
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE04]]
// CK1: br label %[[BEND:.+]]
// CK1: [[BELSE]]:
// CK1: br label %[[BEND]]
// CK1: [[BEND]]:
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
++l;
// CK1: [[T2:%.+]] = load float**, float*** [[DECL:%.+]],
// CK1: [[T1:%.+]] = load float*, float** [[T2]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
// CK1: store float* [[T1]], float** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE05]]
// CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
// CK1: store float* [[VAL]], float** [[PVTV:%.+]],
// CK1-NOT: store float** [[PVTV]], float*** [[DECL]],
// CK1: store float** [[PVTV]], float*** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load float**, float*** [[PVT]],
// CK1: [[TT2:%.+]] = load float*, float** [[TT1]],
// CK1: getelementptr inbounds float, float* [[TT2]], i32 1
#pragma omp target data map(lr[:10]) use_device_ptr(lr)
{
++lr;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE05]]
// CK1: [[TTT:%.+]] = load float**, float*** [[DECL]],
// CK1: [[TTTT:%.+]] = load float*, float** [[TTT]],
// CK1: getelementptr inbounds float, float* [[TTTT]], i32 1
++lr;
// CK1: [[T1:%.+]] = load i32*, i32** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to i32**
// CK1: store i32* [[T1]], i32** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE06]]
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1-NOT: store i32* [[VAL]], i32** [[DECL]],
// CK1: store i32* [[VAL]], i32** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load i32*, i32** [[PVT]],
// CK1: getelementptr inbounds i32, i32* [[TT1]], i32 1
#pragma omp target data map(t[:10]) use_device_ptr(t)
{
++t;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE06]]
// CK1: [[TTT:%.+]] = load i32*, i32** [[DECL]],
// CK1: getelementptr inbounds i32, i32* [[TTT]], i32 1
++t;
// CK1: [[T2:%.+]] = load i32**, i32*** [[DECL:%.+]],
// CK1: [[T1:%.+]] = load i32*, i32** [[T2]],
// CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to i32**
// CK1: store i32* [[T1]], i32** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE07]]
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1: store i32* [[VAL]], i32** [[PVTV:%.+]],
// CK1-NOT: store i32** [[PVTV]], i32*** [[DECL]],
// CK1: store i32** [[PVTV]], i32*** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load i32**, i32*** [[PVT]],
// CK1: [[TT2:%.+]] = load i32*, i32** [[TT1]],
// CK1: getelementptr inbounds i32, i32* [[TT2]], i32 1
#pragma omp target data map(tr[:10]) use_device_ptr(tr)
{
++tr;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE07]]
// CK1: [[TTT:%.+]] = load i32**, i32*** [[DECL]],
// CK1: [[TTTT:%.+]] = load i32*, i32** [[TTT]],
// CK1: getelementptr inbounds i32, i32* [[TTTT]], i32 1
++tr;
// CK1: [[T1:%.+]] = load float*, float** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 0
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
// CK1: store float* [[T1]], float** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE08]]
// CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
// CK1-NOT: store float* [[VAL]], float** [[DECL]],
// CK1: store float* [[VAL]], float** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
// CK1: getelementptr inbounds float, float* [[TT1]], i32 1
#pragma omp target data map(l[:10], t[:10]) use_device_ptr(l)
{
++l; ++t;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE08]]
// CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
// CK1: getelementptr inbounds float, float* [[TTT]], i32 1
++l; ++t;
// CK1: [[_CBP:%.+]] = bitcast i8** {{%.+}} to float**
// CK1: [[CBP:%.+]] = bitcast i8** {{%.+}} to i32**
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE09]]
// CK1: [[_VAL:%.+]] = load float*, float** [[_CBP]],
// CK1: store float* [[_VAL]], float** [[_PVT:%.+]],
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1: store i32* [[VAL]], i32** [[PVT:%.+]],
// CK1: [[_TT1:%.+]] = load float*, float** [[_PVT]],
// CK1: getelementptr inbounds float, float* [[_TT1]], i32 1
// CK1: [[TT1:%.+]] = load i32*, i32** [[PVT]],
// CK1: getelementptr inbounds i32, i32* [[TT1]], i32 1
#pragma omp target data map(l[:10], t[:10]) use_device_ptr(l) use_device_ptr(t)
{
++l; ++t;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE09]]
// CK1: [[_TTT:%.+]] = load float*, float** {{%.+}},
// CK1: getelementptr inbounds float, float* [[_TTT]], i32 1
// CK1: [[TTT:%.+]] = load i32*, i32** {{%.+}},
// CK1: getelementptr inbounds i32, i32* [[TTT]], i32 1
++l; ++t;
// CK1: [[_CBP:%.+]] = bitcast i8** {{%.+}} to float**
// CK1: [[CBP:%.+]] = bitcast i8** {{%.+}} to i32**
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE10]]
// CK1: [[_VAL:%.+]] = load float*, float** [[_CBP]],
// CK1: store float* [[_VAL]], float** [[_PVT:%.+]],
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1: store i32* [[VAL]], i32** [[PVT:%.+]],
// CK1: [[_TT1:%.+]] = load float*, float** [[_PVT]],
// CK1: getelementptr inbounds float, float* [[_TT1]], i32 1
// CK1: [[TT1:%.+]] = load i32*, i32** [[PVT]],
// CK1: getelementptr inbounds i32, i32* [[TT1]], i32 1
#pragma omp target data map(l[:10], t[:10]) use_device_ptr(l,t)
{
++l; ++t;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE10]]
// CK1: [[_TTT:%.+]] = load float*, float** {{%.+}},
// CK1: getelementptr inbounds float, float* [[_TTT]], i32 1
// CK1: [[TTT:%.+]] = load i32*, i32** {{%.+}},
// CK1: getelementptr inbounds i32, i32* [[TTT]], i32 1
++l; ++t;
// CK1: [[T1:%.+]] = load i32*, i32** [[DECL:%.+]],
// CK1: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 1
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to i32**
// CK1: store i32* [[T1]], i32** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE11]]
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1-NOT: store i32* [[VAL]], i32** [[DECL]],
// CK1: store i32* [[VAL]], i32** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load i32*, i32** [[PVT]],
// CK1: getelementptr inbounds i32, i32* [[TT1]], i32 1
#pragma omp target data map(l[:10]) use_device_ptr(t)
{
++l; ++t;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE11]]
// CK1: [[TTT:%.+]] = load i32*, i32** [[DECL]],
// CK1: getelementptr inbounds i32, i32* [[TTT]], i32 1
++l; ++t;
// CK1: [[T2:%.+]] = load i32**, i32*** [[DECL:%.+]],
// CK1: [[T1:%.+]] = load i32*, i32** [[T2]],
// CK1: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 1
// CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to i32**
// CK1: store i32* [[T1]], i32** [[CBP]],
// CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE12]]
// CK1: [[VAL:%.+]] = load i32*, i32** [[CBP]],
// CK1: store i32* [[VAL]], i32** [[PVTV:%.+]],
// CK1-NOT: store i32** [[PVTV]], i32*** [[DECL]],
// CK1: store i32** [[PVTV]], i32*** [[PVT:%.+]],
// CK1: [[TT1:%.+]] = load i32**, i32*** [[PVT]],
// CK1: [[TT2:%.+]] = load i32*, i32** [[TT1]],
// CK1: getelementptr inbounds i32, i32* [[TT2]], i32 1
#pragma omp target data map(l[:10]) use_device_ptr(tr)
{
++l; ++tr;
}
// CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE12]]
// CK1: [[TTT:%.+]] = load i32**, i32*** [[DECL]],
// CK1: [[TTTT:%.+]] = load i32*, i32** [[TTT]],
// CK1: getelementptr inbounds i32, i32* [[TTTT]], i32 1
++l; ++tr;
}
void bar(float *&a, int *&b) {
foo<int>(a,b);
}
#endif
///==========================================================================///
// RUN: %clang_cc1 -DCK2 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
// RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
// RUN: %clang_cc1 -DCK2 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32
// RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32
// RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
// RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
// RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
// RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
#ifdef CK2
// CK2: [[ST:%.+]] = type { double*, double** }
// CK2: [[MTYPE00:@.+]] = {{.*}}constant [2 x i64] [i64 32, i64 281474976710739]
// CK2: [[MTYPE01:@.+]] = {{.*}}constant [2 x i64] [i64 32, i64 281474976710739]
// CK2: [[MTYPE02:@.+]] = {{.*}}constant [3 x i64] [i64 35, i64 32, i64 562949953421392]
// CK2: [[MTYPE03:@.+]] = {{.*}}constant [3 x i64] [i64 32, i64 281474976710739, i64 281474976710736]
template <typename T>
struct ST {
T *a;
double *&b;
ST(double *&b) : a(0), b(b) {}
// CK2-LABEL: @{{.*}}foo{{.*}}
void foo(double *&arg) {
int *la = 0;
// CK2: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 1
// CK2: [[CBP:%.+]] = bitcast i8** [[BP]] to double***
// CK2: store double** [[RVAL:%.+]], double*** [[CBP]],
// CK2: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
// CK2: [[CBP1:%.+]] = bitcast double*** [[CBP]] to double**
// CK2: [[VAL:%.+]] = load double*, double** [[CBP1]],
// CK2: store double* [[VAL]], double** [[PVT:%.+]],
// CK2: store double** [[PVT]], double*** [[PVT2:%.+]],
// CK2: [[TT1:%.+]] = load double**, double*** [[PVT2]],
// CK2: [[TT2:%.+]] = load double*, double** [[TT1]],
// CK2: getelementptr inbounds double, double* [[TT2]], i32 1
#pragma omp target data map(a[:10]) use_device_ptr(a)
{
a++;
}
// CK2: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
// CK2: [[DECL:%.+]] = getelementptr inbounds [[ST]], [[ST]]* %this1, i32 0, i32 0
// CK2: [[TTT:%.+]] = load double*, double** [[DECL]],
// CK2: getelementptr inbounds double, double* [[TTT]], i32 1
a++;
// CK2: [[BP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 1
// CK2: [[CBP:%.+]] = bitcast i8** [[BP]] to double***
// CK2: store double** [[RVAL:%.+]], double*** [[CBP]],
// CK2: call void @__tgt_target_data_begin{{.+}}[[MTYPE01]]
// CK2: [[CBP1:%.+]] = bitcast double*** [[CBP]] to double**
// CK2: [[VAL:%.+]] = load double*, double** [[CBP1]],
// CK2: store double* [[VAL]], double** [[PVT:%.+]],
// CK2: store double** [[PVT]], double*** [[PVT2:%.+]],
// CK2: [[TT1:%.+]] = load double**, double*** [[PVT2]],
// CK2: [[TT2:%.+]] = load double*, double** [[TT1]],
// CK2: getelementptr inbounds double, double* [[TT2]], i32 1
#pragma omp target data map(b[:10]) use_device_ptr(b)
{
b++;
}
// CK2: call void @__tgt_target_data_end{{.+}}[[MTYPE01]]
// CK2: [[DECL:%.+]] = getelementptr inbounds [[ST]], [[ST]]* %{{.+}}, i32 0, i32 1
// CK2: [[TTT:%.+]] = load double**, double*** [[DECL]],
// CK2: [[TTTT:%.+]] = load double*, double** [[TTT]],
// CK2: getelementptr inbounds double, double* [[TTTT]], i32 1
b++;
// CK2: [[BP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* %{{.+}}, i32 0, i32 2
// CK2: [[CBP:%.+]] = bitcast i8** [[BP]] to double***
// CK2: store double** [[RVAL:%.+]], double*** [[CBP]],
// CK2: call void @__tgt_target_data_begin{{.+}}[[MTYPE02]]
// CK2: [[CVAL:%.+]] = bitcast double*** [[CBP]] to double**
// CK2: [[VAL:%.+]] = load double*, double** [[CVAL]],
// CK2: store double* [[VAL]], double** [[PVT:%.+]],
// CK2: store double** [[PVT]], double*** [[PVT2:%.+]],
// CK2: [[TT1:%.+]] = load double**, double*** [[PVT2]],
// CK2: [[TT2:%.+]] = load double*, double** [[TT1]],
// CK2: getelementptr inbounds double, double* [[TT2]], i32 1
#pragma omp target data map(la[:10]) use_device_ptr(a)
{
a++;
la++;
}
// CK2: call void @__tgt_target_data_end{{.+}}[[MTYPE02]]
// CK2: [[DECL:%.+]] = getelementptr inbounds [[ST]], [[ST]]* %this1, i32 0, i32 0
// CK2: [[TTT:%.+]] = load double*, double** [[DECL]],
// CK2: getelementptr inbounds double, double* [[TTT]], i32 1
a++;
la++;
// CK2: [[BP1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* %{{.+}}, i32 0, i32 1
// CK2: [[CBP1:%.+]] = bitcast i8** [[BP1]] to double***
// CK2: store double** [[RVAL1:%.+]], double*** [[CBP1]],
// CK2: [[BP2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* %{{.+}}, i32 0, i32 2
// CK2: [[CBP2:%.+]] = bitcast i8** [[BP2]] to double***
// CK2: store double** [[RVAL2:%.+]], double*** [[CBP2]],
// CK2: call void @__tgt_target_data_begin{{.+}}[[MTYPE03]]
// CK2: [[_CBP2:%.+]] = bitcast double*** [[CBP2]] to double**
// CK2: [[VAL2:%.+]] = load double*, double** [[_CBP2]],
// CK2: store double* [[VAL2]], double** [[PVT2:%.+]],
// CK2: store double** [[PVT2]], double*** [[_PVT2:%.+]],
// CK2: [[_CBP1:%.+]] = bitcast double*** [[CBP1]] to double**
// CK2: [[VAL1:%.+]] = load double*, double** [[_CBP1]],
// CK2: store double* [[VAL1]], double** [[PVT1:%.+]],
// CK2: store double** [[PVT1]], double*** [[_PVT1:%.+]],
// CK2: [[TT2:%.+]] = load double**, double*** [[_PVT2]],
// CK2: [[_TT2:%.+]] = load double*, double** [[TT2]],
// CK2: getelementptr inbounds double, double* [[_TT2]], i32 1
// CK2: [[TT1:%.+]] = load double**, double*** [[_PVT1]],
// CK2: [[_TT1:%.+]] = load double*, double** [[TT1]],
// CK2: getelementptr inbounds double, double* [[_TT1]], i32 1
#pragma omp target data map(b[:10]) use_device_ptr(a, b)
{
a++;
b++;
}
// CK2: call void @__tgt_target_data_end{{.+}}[[MTYPE03]]
// CK2: [[DECL:%.+]] = getelementptr inbounds [[ST]], [[ST]]* %this1, i32 0, i32 0
// CK2: [[TTT:%.+]] = load double*, double** [[DECL]],
// CK2: getelementptr inbounds double, double* [[TTT]], i32 1
// CK2: [[_DECL:%.+]] = getelementptr inbounds [[ST]], [[ST]]* %this1, i32 0, i32 1
// CK2: [[_TTT:%.+]] = load double**, double*** [[_DECL]],
// CK2: [[_TTTT:%.+]] = load double*, double** [[_TTT]],
// CK2: getelementptr inbounds double, double* [[_TTTT]], i32 1
a++;
b++;
}
};
void bar(double *arg){
ST<double> A(arg);
A.foo(arg);
++arg;
}
#endif
#endif