14304e9d1SMichael Kruse // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
24304e9d1SMichael Kruse 
34304e9d1SMichael Kruse // expected-no-diagnostics
44304e9d1SMichael Kruse #ifndef HEADER
54304e9d1SMichael Kruse #define HEADER
64304e9d1SMichael Kruse 
7d47b9438SMichael Kruse ///==========================================================================///
8d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
9d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
10d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
11d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
12d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
13d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
14d47b9438SMichael Kruse 
15d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
16d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
17d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
18d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
19d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
20d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
21d47b9438SMichael Kruse 
22d47b9438SMichael Kruse #ifdef CK0
23*537b16e9SGeorge Rokos // Mapper function code generation and runtime interface.
24d47b9438SMichael Kruse 
25d47b9438SMichael Kruse // CK0-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}.region_id = weak constant i8 0
26d47b9438SMichael Kruse // CK0-64: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
27d47b9438SMichael Kruse // CK0-32: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
28d47b9438SMichael Kruse // CK0: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 35]
29*537b16e9SGeorge Rokos // CK0-64: [[NWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
30*537b16e9SGeorge Rokos // CK0-32: [[NWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
31*537b16e9SGeorge Rokos // CK0: [[NWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 35]
32*537b16e9SGeorge Rokos // CK0-64: [[TEAMSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
33*537b16e9SGeorge Rokos // CK0-32: [[TEAMSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
34*537b16e9SGeorge Rokos // CK0: [[TEAMTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
35*537b16e9SGeorge Rokos // CK0-64: [[TEAMNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
36*537b16e9SGeorge Rokos // CK0-32: [[TEAMNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
37*537b16e9SGeorge Rokos // CK0: [[TEAMNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
38*537b16e9SGeorge Rokos // CK0-64: [[EDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
39*537b16e9SGeorge Rokos // CK0-32: [[EDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
40*537b16e9SGeorge Rokos // CK0: [[EDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
41*537b16e9SGeorge Rokos // CK0-64: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
42*537b16e9SGeorge Rokos // CK0-32: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
43*537b16e9SGeorge Rokos // CK0: [[EDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
44*537b16e9SGeorge Rokos // CK0-64: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
45*537b16e9SGeorge Rokos // CK0-32: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
46*537b16e9SGeorge Rokos // CK0: [[EXDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
47*537b16e9SGeorge Rokos // CK0-64: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
48*537b16e9SGeorge Rokos // CK0-32: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
49*537b16e9SGeorge Rokos // CK0: [[EXDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
50d47b9438SMichael Kruse // CK0-64: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
51d47b9438SMichael Kruse // CK0-32: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
52d47b9438SMichael Kruse // CK0: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
53d47b9438SMichael Kruse // CK0-64: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
54d47b9438SMichael Kruse // CK0-32: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
55d47b9438SMichael Kruse // CK0: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
56*537b16e9SGeorge Rokos // CK0-64: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
57*537b16e9SGeorge Rokos // CK0-32: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
58*537b16e9SGeorge Rokos // CK0: [[FNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
59d47b9438SMichael Kruse 
604304e9d1SMichael Kruse class C {
614304e9d1SMichael Kruse public:
624304e9d1SMichael Kruse   int a;
63d47b9438SMichael Kruse   double *b;
644304e9d1SMichael Kruse };
654304e9d1SMichael Kruse 
66d47b9438SMichael Kruse #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
674304e9d1SMichael Kruse 
68*537b16e9SGeorge Rokos // CK0: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
69d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
70d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
71d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
72d47b9438SMichael Kruse // CK0: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
73d47b9438SMichael Kruse // CK0: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
74*537b16e9SGeorge Rokos // CK0-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
75*537b16e9SGeorge Rokos // CK0-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
76*537b16e9SGeorge Rokos // CK0-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
77d47b9438SMichael Kruse // CK0-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
78d47b9438SMichael Kruse // CK0-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
79d47b9438SMichael Kruse // CK0-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
80d47b9438SMichael Kruse // CK0-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
81d47b9438SMichael Kruse // CK0-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
82d47b9438SMichael Kruse // CK0-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
83d47b9438SMichael Kruse // CK0: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
84d47b9438SMichael Kruse // CK0: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
854304e9d1SMichael Kruse 
86d47b9438SMichael Kruse // CK0: [[INITEVALDEL]]
87d47b9438SMichael Kruse // CK0: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
88d47b9438SMichael Kruse // CK0: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
89d47b9438SMichael Kruse // CK0: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
90d47b9438SMichael Kruse // CK0: [[INIT]]
91d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
92d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
93d47b9438SMichael Kruse // CK0-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
94d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
95d47b9438SMichael Kruse // CK0: br label %[[LHEAD:[^,]+]]
964304e9d1SMichael Kruse 
97d47b9438SMichael Kruse // CK0: [[LHEAD]]
98d47b9438SMichael Kruse // CK0: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
99d47b9438SMichael Kruse // CK0: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
100d47b9438SMichael Kruse // CK0: [[LBODY]]
101d47b9438SMichael Kruse // CK0: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
102d47b9438SMichael Kruse // CK0: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
103d47b9438SMichael Kruse // CK0-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 0
104d47b9438SMichael Kruse // CK0-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
105d47b9438SMichael Kruse // CK0-DAG: [[BBEGIN2:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
106d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGIN:%.+]] = load double*, double** [[BBEGIN2]]
107d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGINGEP:%.+]] = getelementptr inbounds double, double* [[BARRBEGIN]], i[[sz:64|32]] 0
108d47b9438SMichael Kruse // CK0-DAG: [[BEND:%.+]] = getelementptr double*, double** [[BBEGIN]], i32 1
109d47b9438SMichael Kruse // CK0-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
110d47b9438SMichael Kruse // CK0-DAG: [[BENDV:%.+]] = bitcast double** [[BEND]] to i8*
111d47b9438SMichael Kruse // CK0-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
112d47b9438SMichael Kruse // CK0-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
113d47b9438SMichael Kruse // CK0-DAG: [[CSIZE:%.+]] = sub i64 [[BENDI]], [[ABEGINI]]
114d47b9438SMichael Kruse // CK0-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
115d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
116d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
117d47b9438SMichael Kruse // CK0-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
118d47b9438SMichael Kruse // CK0-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
119d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
120d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
121d47b9438SMichael Kruse // CK0-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
122d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
123d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 32, [[SHIPRESIZE]]
124d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
125d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
126d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 32, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
127d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
128d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
129d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
130d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
131d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
132d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
133d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
134d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
135d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
136d47b9438SMichael Kruse // CK0-DAG: [[TO]]
137d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
138d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
139d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
140d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
141d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
142d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
143d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
144d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
145d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
146d47b9438SMichael Kruse // CK0-DAG: [[PHITYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
147d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[PHITYPE0]])
148d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
149d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
150d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
151d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
152d47b9438SMichael Kruse // CK0-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
153d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
154d47b9438SMichael Kruse // 281474976710659 == 0x1,000,000,003
155d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
156d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
157d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
158d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710659, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
159d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
160d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
161d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
162d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
163d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
164d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
165d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
166d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
167d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
168d47b9438SMichael Kruse // CK0-DAG: [[TO]]
169d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
170d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
171d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
172d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
173d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
174d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
175d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
176d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
177d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
178d47b9438SMichael Kruse // CK0-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
179d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]])
180d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR2BC:%.+]] = bitcast double** [[BBEGIN]] to i8*
181d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR2BC:%.+]] = bitcast double* [[BARRBEGINGEP]] to i8*
182d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
183d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
184d47b9438SMichael Kruse // CK0-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
185d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
186d47b9438SMichael Kruse // 281474976710675 == 0x1,000,000,013
187d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710675, [[SHIPRESIZE]]
188d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
189d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
190d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710675, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
191d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
192d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
193d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
194d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
195d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
196d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
197d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
198d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
199d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
200d47b9438SMichael Kruse // CK0-DAG: [[TO]]
201d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
202d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
203d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
204d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
205d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
206d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
207d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
208d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
209d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
210d47b9438SMichael Kruse // CK0-DAG: [[TYPE2:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
211d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR2BC]], i8* [[PTRADDR2BC]], i64 16, i64 [[TYPE2]])
212d47b9438SMichael Kruse // CK0: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
213d47b9438SMichael Kruse // CK0: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
214d47b9438SMichael Kruse // CK0: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
215d47b9438SMichael Kruse 
216d47b9438SMichael Kruse // CK0: [[LEXIT]]
217d47b9438SMichael Kruse // CK0: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
218d47b9438SMichael Kruse // CK0: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
219d47b9438SMichael Kruse // CK0: [[EVALDEL]]
220d47b9438SMichael Kruse // CK0: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
221d47b9438SMichael Kruse // CK0: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
222d47b9438SMichael Kruse // CK0: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
223d47b9438SMichael Kruse // CK0: [[DEL]]
224d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
225d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
226d47b9438SMichael Kruse // CK0-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
227d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
228d47b9438SMichael Kruse // CK0: br label %[[DONE]]
229d47b9438SMichael Kruse // CK0: [[DONE]]
230d47b9438SMichael Kruse // CK0: ret void
231d47b9438SMichael Kruse 
232d47b9438SMichael Kruse 
233d47b9438SMichael Kruse // CK0-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
2344304e9d1SMichael Kruse void foo(int a){
2354304e9d1SMichael Kruse   int i = a;
2364304e9d1SMichael Kruse   C c;
2374304e9d1SMichael Kruse   c.a = a;
2384304e9d1SMichael Kruse 
239*537b16e9SGeorge Rokos   // CK0-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
240d47b9438SMichael Kruse   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
241d47b9438SMichael Kruse   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
242*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
243d47b9438SMichael Kruse   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
244d47b9438SMichael Kruse   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
245*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
246d47b9438SMichael Kruse   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
247d47b9438SMichael Kruse   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
248d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
249d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
250*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
251d47b9438SMichael Kruse   // CK0: call void [[KERNEL:@.+]](%class.C* [[VAL]])
2524304e9d1SMichael Kruse   #pragma omp target map(mapper(id),tofrom: c)
2534304e9d1SMichael Kruse   {
2544304e9d1SMichael Kruse     ++c.a;
2554304e9d1SMichael Kruse   }
25601f670dfSMichael Kruse 
257*537b16e9SGeorge Rokos   // CK0-DAG: call i32 @__tgt_target_nowait_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[NWSIZES]]{{.+}}, {{.+}}[[NWTYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
258*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
259*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
260*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
261*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
262*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
263*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
264*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
265*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
266*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
267*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
268*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
269*537b16e9SGeorge Rokos   // CK0: call void [[KERNEL:@.+]](%class.C* [[VAL]])
270*537b16e9SGeorge Rokos   #pragma omp target map(mapper(id),tofrom: c) nowait
271*537b16e9SGeorge Rokos   {
272*537b16e9SGeorge Rokos     ++c.a;
273*537b16e9SGeorge Rokos   }
274*537b16e9SGeorge Rokos 
275*537b16e9SGeorge Rokos   // CK0-DAG: call i32 @__tgt_target_teams_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[TEAMSIZES]]{{.+}}, {{.+}}[[TEAMTYPES]]{{.+}}, i8** [[MPRGEP:%.+]], i32 0, i32 0)
276*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
277*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
278*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
279*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
280*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
281*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
282*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
283*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
284*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
285*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
286*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
287*537b16e9SGeorge Rokos   // CK0: call void [[KERNEL:@.+]](%class.C* [[VAL]])
288*537b16e9SGeorge Rokos   #pragma omp target teams map(mapper(id),to: c)
289*537b16e9SGeorge Rokos   {
290*537b16e9SGeorge Rokos     ++c.a;
291*537b16e9SGeorge Rokos   }
292*537b16e9SGeorge Rokos 
293*537b16e9SGeorge Rokos   // CK0-DAG: call i32 @__tgt_target_teams_nowait_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[TEAMNWSIZES]]{{.+}}, {{.+}}[[TEAMNWTYPES]]{{.+}}, i8** [[MPRGEP:%.+]], i32 0, i32 0)
294*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
295*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
296*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
297*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
298*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
299*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
300*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
301*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
302*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
303*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
304*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
305*537b16e9SGeorge Rokos   // CK0: call void [[KERNEL:@.+]](%class.C* [[VAL]])
306*537b16e9SGeorge Rokos   #pragma omp target teams map(mapper(id),to: c) nowait
307*537b16e9SGeorge Rokos   {
308*537b16e9SGeorge Rokos     ++c.a;
309*537b16e9SGeorge Rokos   }
310*537b16e9SGeorge Rokos 
311*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_begin_mapper(i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EDSIZES]]{{.+}}, {{.+}}[[EDTYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
312*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
313*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
314*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
315*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
316*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
317*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
318*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
319*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
320*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
321*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
322*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
323*537b16e9SGeorge Rokos   #pragma omp target enter data map(mapper(id),to: c)
324*537b16e9SGeorge Rokos 
325*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_begin_nowait_mapper(i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EDNWSIZES]]{{.+}}, {{.+}}[[EDNWTYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
326*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
327*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
328*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
329*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
330*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
331*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
332*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
333*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
334*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
335*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
336*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
337*537b16e9SGeorge Rokos   #pragma omp target enter data map(mapper(id),to: c) nowait
338*537b16e9SGeorge Rokos 
339*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_end_mapper(i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EXDSIZES]]{{.+}}, {{.+}}[[EXDTYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
340*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
341*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
342*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
343*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
344*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
345*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
346*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
347*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
348*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
349*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
350*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
351*537b16e9SGeorge Rokos   #pragma omp target exit data map(mapper(id),from: c)
352*537b16e9SGeorge Rokos 
353*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_end_nowait_mapper(i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EXDNWSIZES]]{{.+}}, {{.+}}[[EXDNWTYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
354*537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
355*537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
356*537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
357*537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
358*537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
359*537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
360*537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
361*537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
362*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
363*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
364*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
365*537b16e9SGeorge Rokos   #pragma omp target exit data map(mapper(id),from: c) nowait
366*537b16e9SGeorge Rokos 
367*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 1, i8** [[TGEPBP:%.+]], i8** [[TGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[TSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[TTYPES]]{{.+}}, i8** [[TMPRGEP:%.+]])
368d47b9438SMichael Kruse   // CK0-DAG: [[TGEPBP]] = getelementptr inbounds {{.+}}[[TBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
369d47b9438SMichael Kruse   // CK0-DAG: [[TGEPP]] = getelementptr inbounds {{.+}}[[TP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
370*537b16e9SGeorge Rokos   // CK0-DAG: [[TMPRGEP]] = bitcast [1 x i8*]* [[TMPR:%[^,]+]] to i8**
371d47b9438SMichael Kruse   // CK0-DAG: [[TBP0:%.+]] = getelementptr inbounds {{.+}}[[TBP]], i{{.+}} 0, i{{.+}} 0
372d47b9438SMichael Kruse   // CK0-DAG: [[TP0:%.+]] = getelementptr inbounds {{.+}}[[TP]], i{{.+}} 0, i{{.+}} 0
373*537b16e9SGeorge Rokos   // CK0-DAG: [[TMPR1:%.+]] = getelementptr inbounds {{.+}}[[TMPR]], i[[sz]] 0, i[[sz]] 0
374d47b9438SMichael Kruse   // CK0-DAG: [[TCBP0:%.+]] = bitcast i8** [[TBP0]] to %class.C**
375d47b9438SMichael Kruse   // CK0-DAG: [[TCP0:%.+]] = bitcast i8** [[TP0]] to %class.C**
376d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[TCBP0]]
377d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[TCP0]]
378*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[TMPR1]]
37901f670dfSMichael Kruse   #pragma omp target update to(mapper(id): c)
3800336c75cSMichael Kruse 
381*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 1, i8** [[FGEPBP:%.+]], i8** [[FGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[FSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[FTYPES]]{{.+}}, i8** [[FMPRGEP:%.+]])
382d47b9438SMichael Kruse   // CK0-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
383d47b9438SMichael Kruse   // CK0-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
384*537b16e9SGeorge Rokos   // CK0-DAG: [[FMPRGEP]] = bitcast [1 x i8*]* [[FMPR:%[^,]+]] to i8**
385d47b9438SMichael Kruse   // CK0-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0
386d47b9438SMichael Kruse   // CK0-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0
387*537b16e9SGeorge Rokos   // CK0-DAG: [[FMPR1:%.+]] = getelementptr inbounds {{.+}}[[FMPR]], i[[sz]] 0, i[[sz]] 0
388d47b9438SMichael Kruse   // CK0-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C**
389d47b9438SMichael Kruse   // CK0-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C**
390d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]]
391d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]]
392*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[FMPR1]]
3930336c75cSMichael Kruse   #pragma omp target update from(mapper(id): c)
394*537b16e9SGeorge Rokos 
395*537b16e9SGeorge Rokos   // CK0-DAG: call void @__tgt_target_data_update_nowait_mapper(i64 -1, i32 1, i8** [[FGEPBP:%.+]], i8** [[FGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[FNWSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[FNWTYPES]]{{.+}}, i8** [[FMPRGEP:%.+]])
396*537b16e9SGeorge Rokos   // CK0-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
397*537b16e9SGeorge Rokos   // CK0-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
398*537b16e9SGeorge Rokos   // CK0-DAG: [[FMPRGEP]] = bitcast [1 x i8*]* [[FMPR:%[^,]+]] to i8**
399*537b16e9SGeorge Rokos   // CK0-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0
400*537b16e9SGeorge Rokos   // CK0-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0
401*537b16e9SGeorge Rokos   // CK0-DAG: [[FMPR1:%.+]] = getelementptr inbounds {{.+}}[[FMPR]], i[[sz]] 0, i[[sz]] 0
402*537b16e9SGeorge Rokos   // CK0-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C**
403*537b16e9SGeorge Rokos   // CK0-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C**
404*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]]
405*537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]]
406*537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[FMPR1]]
407*537b16e9SGeorge Rokos   #pragma omp target update from(mapper(id): c) nowait
4084304e9d1SMichael Kruse }
4094304e9d1SMichael Kruse 
4104304e9d1SMichael Kruse 
411d47b9438SMichael Kruse // CK0: define internal void [[KERNEL]](%class.C* {{.+}}[[ARG:%.+]])
412d47b9438SMichael Kruse // CK0: [[ADDR:%.+]] = alloca %class.C*,
413d47b9438SMichael Kruse // CK0: store %class.C* [[ARG]], %class.C** [[ADDR]]
414d47b9438SMichael Kruse // CK0: [[CADDR:%.+]] = load %class.C*, %class.C** [[ADDR]]
415d47b9438SMichael Kruse // CK0: [[CAADDR:%.+]] = getelementptr inbounds %class.C, %class.C* [[CADDR]], i32 0, i32 0
416d47b9438SMichael Kruse // CK0: [[VAL:%[^,]+]] = load i32, i32* [[CAADDR]]
417d47b9438SMichael Kruse // CK0: {{.+}} = add nsw i32 [[VAL]], 1
418d47b9438SMichael Kruse // CK0: }
419d47b9438SMichael Kruse 
420*537b16e9SGeorge Rokos #endif // CK0
421d47b9438SMichael Kruse 
422d47b9438SMichael Kruse 
423d47b9438SMichael Kruse ///==========================================================================///
424d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK1 --check-prefix CK1-64 %s
425d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
426d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK1 --check-prefix CK1-64 %s
427d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK1 --check-prefix CK1-32 %s
428d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
429d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK1 --check-prefix CK1-32 %s
430d47b9438SMichael Kruse 
431d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
432d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
433d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
434d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
435d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
436d47b9438SMichael Kruse // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
437d47b9438SMichael Kruse 
438d47b9438SMichael Kruse #ifdef CK1
439*537b16e9SGeorge Rokos // C++ template
440d47b9438SMichael Kruse 
441d47b9438SMichael Kruse template <class T>
442d47b9438SMichael Kruse class C {
443d47b9438SMichael Kruse public:
444d47b9438SMichael Kruse   T a;
445d47b9438SMichael Kruse };
446d47b9438SMichael Kruse 
447d47b9438SMichael Kruse #pragma omp declare mapper(id: C<int> s) map(s.a)
448d47b9438SMichael Kruse 
449d47b9438SMichael Kruse // CK1-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id{{.*}}(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
450d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
451d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
452d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
453d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
454d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
455*537b16e9SGeorge Rokos // CK1-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
456*537b16e9SGeorge Rokos // CK1-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 4
457d47b9438SMichael Kruse // CK1-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
458d47b9438SMichael Kruse // CK1-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
459d47b9438SMichael Kruse // CK1-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
460d47b9438SMichael Kruse // CK1-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
461d47b9438SMichael Kruse // CK1-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
462d47b9438SMichael Kruse // CK1-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
463d47b9438SMichael Kruse // CK1: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
464d47b9438SMichael Kruse // CK1: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
465d47b9438SMichael Kruse 
466d47b9438SMichael Kruse // CK1: [[INITEVALDEL]]
467d47b9438SMichael Kruse // CK1: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
468d47b9438SMichael Kruse // CK1: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
469d47b9438SMichael Kruse // CK1: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
470d47b9438SMichael Kruse // CK1: [[INIT]]
471d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
472d47b9438SMichael Kruse // CK1-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
473d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
474d47b9438SMichael Kruse // CK1: br label %[[LHEAD:[^,]+]]
475d47b9438SMichael Kruse 
476d47b9438SMichael Kruse // CK1: [[LHEAD]]
477d47b9438SMichael Kruse // CK1: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
478d47b9438SMichael Kruse // CK1: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
479d47b9438SMichael Kruse // CK1: [[LBODY]]
480d47b9438SMichael Kruse // CK1: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
481d47b9438SMichael Kruse // CK1: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
482d47b9438SMichael Kruse // CK1-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 0
483d47b9438SMichael Kruse // CK1-DAG: [[AEND:%.+]] = getelementptr i32, i32* [[ABEGIN]], i32 1
484d47b9438SMichael Kruse // CK1-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
485d47b9438SMichael Kruse // CK1-DAG: [[AENDV:%.+]] = bitcast i32* [[AEND]] to i8*
486d47b9438SMichael Kruse // CK1-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
487d47b9438SMichael Kruse // CK1-DAG: [[AENDI:%.+]] = ptrtoint i8* [[AENDV]] to i64
488d47b9438SMichael Kruse // CK1-DAG: [[CSIZE:%.+]] = sub i64 [[AENDI]], [[ABEGINI]]
489d47b9438SMichael Kruse // CK1-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
490d47b9438SMichael Kruse // CK1-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
491d47b9438SMichael Kruse // CK1-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
492d47b9438SMichael Kruse // CK1-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
493d47b9438SMichael Kruse // CK1-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
494d47b9438SMichael Kruse // CK1-DAG: br label %[[MEMBER:[^,]+]]
495d47b9438SMichael Kruse // CK1-DAG: [[MEMBER]]
496d47b9438SMichael Kruse // CK1-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
497d47b9438SMichael Kruse // CK1-DAG: [[MEMBERCOM]]
498d47b9438SMichael Kruse // CK1-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 32, [[SHIPRESIZE]]
499d47b9438SMichael Kruse // CK1-DAG: br label %[[LTYPE]]
500d47b9438SMichael Kruse // CK1-DAG: [[LTYPE]]
501d47b9438SMichael Kruse // CK1-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 32, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
502d47b9438SMichael Kruse // CK1-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
503d47b9438SMichael Kruse // CK1-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
504d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
505d47b9438SMichael Kruse // CK1-DAG: [[ALLOC]]
506d47b9438SMichael Kruse // CK1-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
507d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND:[^,]+]]
508d47b9438SMichael Kruse // CK1-DAG: [[ALLOCELSE]]
509d47b9438SMichael Kruse // CK1-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
510d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
511d47b9438SMichael Kruse // CK1-DAG: [[TO]]
512d47b9438SMichael Kruse // CK1-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
513d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
514d47b9438SMichael Kruse // CK1-DAG: [[TOELSE]]
515d47b9438SMichael Kruse // CK1-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
516d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
517d47b9438SMichael Kruse // CK1-DAG: [[FROM]]
518d47b9438SMichael Kruse // CK1-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
519d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
520d47b9438SMichael Kruse // CK1-DAG: [[TYEND]]
521d47b9438SMichael Kruse // CK1-DAG: [[TYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
522d47b9438SMichael Kruse // CK1-64: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[TYPE0]])
523d47b9438SMichael Kruse // CK1-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
524d47b9438SMichael Kruse // CK1-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
525d47b9438SMichael Kruse // CK1-DAG: br label %[[MEMBER:[^,]+]]
526d47b9438SMichael Kruse // CK1-DAG: [[MEMBER]]
527d47b9438SMichael Kruse // CK1-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
528d47b9438SMichael Kruse // CK1-DAG: [[MEMBERCOM]]
529d47b9438SMichael Kruse // 281474976710659 == 0x1,000,000,003
530d47b9438SMichael Kruse // CK1-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
531d47b9438SMichael Kruse // CK1-DAG: br label %[[LTYPE]]
532d47b9438SMichael Kruse // CK1-DAG: [[LTYPE]]
533d47b9438SMichael Kruse // CK1-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710659, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
534d47b9438SMichael Kruse // CK1-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
535d47b9438SMichael Kruse // CK1-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
536d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
537d47b9438SMichael Kruse // CK1-DAG: [[ALLOC]]
538d47b9438SMichael Kruse // CK1-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
539d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND:[^,]+]]
540d47b9438SMichael Kruse // CK1-DAG: [[ALLOCELSE]]
541d47b9438SMichael Kruse // CK1-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
542d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
543d47b9438SMichael Kruse // CK1-DAG: [[TO]]
544d47b9438SMichael Kruse // CK1-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
545d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
546d47b9438SMichael Kruse // CK1-DAG: [[TOELSE]]
547d47b9438SMichael Kruse // CK1-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
548d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
549d47b9438SMichael Kruse // CK1-DAG: [[FROM]]
550d47b9438SMichael Kruse // CK1-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
551d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
552d47b9438SMichael Kruse // CK1-DAG: [[TYEND]]
553d47b9438SMichael Kruse // CK1-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
554d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]])
555d47b9438SMichael Kruse // CK1: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
556d47b9438SMichael Kruse // CK1: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
557d47b9438SMichael Kruse // CK1: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
558d47b9438SMichael Kruse 
559d47b9438SMichael Kruse // CK1: [[LEXIT]]
560d47b9438SMichael Kruse // CK1: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
561d47b9438SMichael Kruse // CK1: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
562d47b9438SMichael Kruse // CK1: [[EVALDEL]]
563d47b9438SMichael Kruse // CK1: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
564d47b9438SMichael Kruse // CK1: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
565d47b9438SMichael Kruse // CK1: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
566d47b9438SMichael Kruse // CK1: [[DEL]]
567d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
568d47b9438SMichael Kruse // CK1-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
569d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
570d47b9438SMichael Kruse // CK1: br label %[[DONE]]
571d47b9438SMichael Kruse // CK1: [[DONE]]
572d47b9438SMichael Kruse // CK1: ret void
573d47b9438SMichael Kruse 
574*537b16e9SGeorge Rokos #endif // CK1
5754304e9d1SMichael Kruse 
576*537b16e9SGeorge Rokos 
577*537b16e9SGeorge Rokos ///==========================================================================///
578*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK2 --check-prefix CK2-64 %s
579*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
580*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK2 --check-prefix CK2-64 %s
581*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK2 --check-prefix CK2-32 %s
582*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
583*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK2 --check-prefix CK2-32 %s
584*537b16e9SGeorge Rokos 
585*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
586*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
587*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
588*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
589*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
590*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK2 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
591*537b16e9SGeorge Rokos 
592*537b16e9SGeorge Rokos #ifdef CK2
593*537b16e9SGeorge Rokos // Nested mappers.
594*537b16e9SGeorge Rokos 
595*537b16e9SGeorge Rokos class B {
596*537b16e9SGeorge Rokos public:
597*537b16e9SGeorge Rokos   double a;
598*537b16e9SGeorge Rokos };
599*537b16e9SGeorge Rokos 
600*537b16e9SGeorge Rokos class C {
601*537b16e9SGeorge Rokos public:
602*537b16e9SGeorge Rokos   double a;
603*537b16e9SGeorge Rokos   B b;
604*537b16e9SGeorge Rokos };
605*537b16e9SGeorge Rokos 
606*537b16e9SGeorge Rokos #pragma omp declare mapper(B s) map(s.a)
607*537b16e9SGeorge Rokos 
608*537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.b)
609*537b16e9SGeorge Rokos 
610*537b16e9SGeorge Rokos // CK2: define {{.*}}void [[BMPRFUNC:@[.]omp_mapper[.].*B[.]default]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
611*537b16e9SGeorge Rokos 
612*537b16e9SGeorge Rokos // CK2-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
613*537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
614*537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
615*537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
616*537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
617*537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
618*537b16e9SGeorge Rokos // CK2-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
619*537b16e9SGeorge Rokos // CK2-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
620*537b16e9SGeorge Rokos // CK2-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
621*537b16e9SGeorge Rokos // CK2-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
622*537b16e9SGeorge Rokos // CK2-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
623*537b16e9SGeorge Rokos // CK2-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
624*537b16e9SGeorge Rokos // CK2-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
625*537b16e9SGeorge Rokos // CK2-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
626*537b16e9SGeorge Rokos // CK2: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
627*537b16e9SGeorge Rokos // CK2: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
628*537b16e9SGeorge Rokos 
629*537b16e9SGeorge Rokos // CK2: [[INITEVALDEL]]
630*537b16e9SGeorge Rokos // CK2: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
631*537b16e9SGeorge Rokos // CK2: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
632*537b16e9SGeorge Rokos // CK2: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
633*537b16e9SGeorge Rokos // CK2: [[INIT]]
634*537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
635*537b16e9SGeorge Rokos // CK2-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
636*537b16e9SGeorge Rokos // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
637*537b16e9SGeorge Rokos // CK2: br label %[[LHEAD:[^,]+]]
638*537b16e9SGeorge Rokos 
639*537b16e9SGeorge Rokos // CK2: [[LHEAD]]
640*537b16e9SGeorge Rokos // CK2: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
641*537b16e9SGeorge Rokos // CK2: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
642*537b16e9SGeorge Rokos // CK2: [[LBODY]]
643*537b16e9SGeorge Rokos // CK2: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
644*537b16e9SGeorge Rokos // CK2: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
645*537b16e9SGeorge Rokos // CK2-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
646*537b16e9SGeorge Rokos // CK2-DAG: [[BEND:%.+]] = getelementptr %class.B, %class.B* [[BBEGIN]], i32 1
647*537b16e9SGeorge Rokos // CK2-DAG: [[BBEGINV:%.+]] = bitcast %class.B* [[BBEGIN]] to i8*
648*537b16e9SGeorge Rokos // CK2-DAG: [[BENDV:%.+]] = bitcast %class.B* [[BEND]] to i8*
649*537b16e9SGeorge Rokos // CK2-DAG: [[BBEGINI:%.+]] = ptrtoint i8* [[BBEGINV]] to i64
650*537b16e9SGeorge Rokos // CK2-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
651*537b16e9SGeorge Rokos // CK2-DAG: [[BSIZE:%.+]] = sub i64 [[BENDI]], [[BBEGINI]]
652*537b16e9SGeorge Rokos // CK2-DAG: [[BUSIZE:%.+]] = sdiv exact i64 [[BSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
653*537b16e9SGeorge Rokos // CK2-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
654*537b16e9SGeorge Rokos // CK2-DAG: [[PTRADDR0BC:%.+]] = bitcast %class.B* [[BBEGIN]] to i8*
655*537b16e9SGeorge Rokos // CK2-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
656*537b16e9SGeorge Rokos // CK2-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
657*537b16e9SGeorge Rokos // CK2-DAG: br label %[[MEMBER:[^,]+]]
658*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBER]]
659*537b16e9SGeorge Rokos // CK2-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
660*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERCOM]]
661*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 32, [[SHIPRESIZE]]
662*537b16e9SGeorge Rokos // CK2-DAG: br label %[[LTYPE]]
663*537b16e9SGeorge Rokos // CK2-DAG: [[LTYPE]]
664*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 32, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
665*537b16e9SGeorge Rokos // CK2-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
666*537b16e9SGeorge Rokos // CK2-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
667*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
668*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOC]]
669*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
670*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND:[^,]+]]
671*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCELSE]]
672*537b16e9SGeorge Rokos // CK2-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
673*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
674*537b16e9SGeorge Rokos // CK2-DAG: [[TO]]
675*537b16e9SGeorge Rokos // CK2-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
676*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
677*537b16e9SGeorge Rokos // CK2-DAG: [[TOELSE]]
678*537b16e9SGeorge Rokos // CK2-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
679*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
680*537b16e9SGeorge Rokos // CK2-DAG: [[FROM]]
681*537b16e9SGeorge Rokos // CK2-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
682*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
683*537b16e9SGeorge Rokos // CK2-DAG: [[TYEND]]
684*537b16e9SGeorge Rokos // CK2-DAG: [[TYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
685*537b16e9SGeorge Rokos // CK2-64: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[BUSIZE]], i64 [[TYPE0]])
686*537b16e9SGeorge Rokos // CK2-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
687*537b16e9SGeorge Rokos // CK2-DAG: [[PTRADDR1BC:%.+]] = bitcast %class.B* [[BBEGIN]] to i8*
688*537b16e9SGeorge Rokos // CK2-DAG: br label %[[MEMBER:[^,]+]]
689*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBER]]
690*537b16e9SGeorge Rokos // CK2-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
691*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERCOM]]
692*537b16e9SGeorge Rokos // 281474976710659 == 0x1,000,000,003
693*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
694*537b16e9SGeorge Rokos // CK2-DAG: br label %[[LTYPE]]
695*537b16e9SGeorge Rokos // CK2-DAG: [[LTYPE]]
696*537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710659, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
697*537b16e9SGeorge Rokos // CK2-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
698*537b16e9SGeorge Rokos // CK2-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
699*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
700*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOC]]
701*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
702*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND:[^,]+]]
703*537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCELSE]]
704*537b16e9SGeorge Rokos // CK2-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
705*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
706*537b16e9SGeorge Rokos // CK2-DAG: [[TO]]
707*537b16e9SGeorge Rokos // CK2-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
708*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
709*537b16e9SGeorge Rokos // CK2-DAG: [[TOELSE]]
710*537b16e9SGeorge Rokos // CK2-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
711*537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
712*537b16e9SGeorge Rokos // CK2-DAG: [[FROM]]
713*537b16e9SGeorge Rokos // CK2-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
714*537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
715*537b16e9SGeorge Rokos // CK2-DAG: [[TYEND]]
716*537b16e9SGeorge Rokos // CK2-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
717*537b16e9SGeorge Rokos // CK2: call void [[BMPRFUNC]](i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 8, i64 [[TYPE1]])
718*537b16e9SGeorge Rokos // CK2: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
719*537b16e9SGeorge Rokos // CK2: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
720*537b16e9SGeorge Rokos // CK2: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
721*537b16e9SGeorge Rokos 
722*537b16e9SGeorge Rokos // CK2: [[LEXIT]]
723*537b16e9SGeorge Rokos // CK2: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
724*537b16e9SGeorge Rokos // CK2: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
725*537b16e9SGeorge Rokos // CK2: [[EVALDEL]]
726*537b16e9SGeorge Rokos // CK2: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
727*537b16e9SGeorge Rokos // CK2: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
728*537b16e9SGeorge Rokos // CK2: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
729*537b16e9SGeorge Rokos // CK2: [[DEL]]
730*537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
731*537b16e9SGeorge Rokos // CK2-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
732*537b16e9SGeorge Rokos // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
733*537b16e9SGeorge Rokos // CK2: br label %[[DONE]]
734*537b16e9SGeorge Rokos // CK2: [[DONE]]
735*537b16e9SGeorge Rokos // CK2: ret void
736*537b16e9SGeorge Rokos 
737*537b16e9SGeorge Rokos #endif // CK2
738*537b16e9SGeorge Rokos 
739*537b16e9SGeorge Rokos 
740*537b16e9SGeorge Rokos ///==========================================================================///
741*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK3 %s
742*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
743*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK3 %s
744*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK3 %s
745*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
746*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK3 %s
747*537b16e9SGeorge Rokos 
748*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
749*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
750*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
751*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
752*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
753*537b16e9SGeorge Rokos // RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
754*537b16e9SGeorge Rokos 
755*537b16e9SGeorge Rokos #ifdef CK3
756*537b16e9SGeorge Rokos // map of array sections and nested components.
757*537b16e9SGeorge Rokos 
758*537b16e9SGeorge Rokos // CK3-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}.region_id = weak constant i8 0
759*537b16e9SGeorge Rokos // CK3: [[TYPES:@.+]] = {{.+}}constant [3 x i64] [i64 32, i64 281474976710659, i64 35]
760*537b16e9SGeorge Rokos 
761*537b16e9SGeorge Rokos class C {
762*537b16e9SGeorge Rokos public:
763*537b16e9SGeorge Rokos   int a;
764*537b16e9SGeorge Rokos   double *b;
765*537b16e9SGeorge Rokos };
766*537b16e9SGeorge Rokos 
767*537b16e9SGeorge Rokos class B {
768*537b16e9SGeorge Rokos public:
769*537b16e9SGeorge Rokos   C c;
770*537b16e9SGeorge Rokos };
771*537b16e9SGeorge Rokos 
772*537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
773*537b16e9SGeorge Rokos 
774*537b16e9SGeorge Rokos // CK3: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
775*537b16e9SGeorge Rokos 
776*537b16e9SGeorge Rokos // CK3-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
777*537b16e9SGeorge Rokos void foo(int a){
778*537b16e9SGeorge Rokos   // CK3-DAG: [[CVAL:%.+]] = alloca [10 x %class.C]
779*537b16e9SGeorge Rokos   // CK3-DAG: [[BVAL:%.+]] = alloca %class.B
780*537b16e9SGeorge Rokos   C c[10];
781*537b16e9SGeorge Rokos   B b;
782*537b16e9SGeorge Rokos 
783*537b16e9SGeorge Rokos   // CK3-DAG: [[BC:%.+]] = getelementptr inbounds %class.B, %class.B* [[BVAL]], i32 0, i32 0
784*537b16e9SGeorge Rokos   // CK3-DAG: [[BCEND:%.+]] = getelementptr %class.C, %class.C* [[BC]], i32 1
785*537b16e9SGeorge Rokos   // CK3-DAG: [[BCC:%.+]] = bitcast %class.C* [[BC]] to i8*
786*537b16e9SGeorge Rokos   // CK3-DAG: [[BCENDC:%.+]] = bitcast %class.C* [[BCEND]] to i8*
787*537b16e9SGeorge Rokos   // CK3-DAG: [[BCI:%.+]] = ptrtoint i8* [[BCC]] to i64
788*537b16e9SGeorge Rokos   // CK3-DAG: [[BCENDI:%.+]] = ptrtoint i8* [[BCENDC]] to i64
789*537b16e9SGeorge Rokos   // CK3-DAG: [[BSIZE:%.+]] = sub i64 [[BCENDI]], [[BCI]]
790*537b16e9SGeorge Rokos   // CK3-DAG: [[BSIZED:%.+]] = sdiv exact i64 [[BSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
791*537b16e9SGeorge Rokos 
792*537b16e9SGeorge Rokos   // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 3, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], i64* [[SGEP:%[^,]+]], {{.+}}[[TYPES]]{{.+}}, i8** [[MPRGEP:%.+]])
793*537b16e9SGeorge Rokos   // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
794*537b16e9SGeorge Rokos   // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
795*537b16e9SGeorge Rokos   // CK3-DAG: [[SGEP]] = getelementptr inbounds {{.+}}[[SIZES:%[^,]+]], i32 0, i32 0
796*537b16e9SGeorge Rokos   // CK3-DAG: [[MPRGEP]] = bitcast [3 x i8*]* [[MPR:%[^,]+]] to i8**
797*537b16e9SGeorge Rokos   // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
798*537b16e9SGeorge Rokos   // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
799*537b16e9SGeorge Rokos   // CK3-DAG: [[S1:%.+]] = getelementptr inbounds {{.+}}[[SIZES]], i32 0, i32 0
800*537b16e9SGeorge Rokos   // CK3-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 0
801*537b16e9SGeorge Rokos   // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.B**
802*537b16e9SGeorge Rokos   // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
803*537b16e9SGeorge Rokos   // CK3-DAG: store %class.B* [[BVAL]], %class.B** [[CBP1]]
804*537b16e9SGeorge Rokos   // CK3-DAG: store %class.C* [[BC]], %class.C** [[CP1]]
805*537b16e9SGeorge Rokos   // CK3-DAG: store i64 [[BSIZED]], i64* [[S1]]
806*537b16e9SGeorge Rokos   // CK3-DAG: store i8* null, i8** [[MPR1]]
807*537b16e9SGeorge Rokos   // CK3-DAG: [[BP2:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 1
808*537b16e9SGeorge Rokos   // CK3-DAG: [[P2:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 1
809*537b16e9SGeorge Rokos   // CK3-DAG: [[S2:%.+]] = getelementptr inbounds {{.+}}[[SIZES]], i32 0, i32 1
810*537b16e9SGeorge Rokos   // CK3-DAG: [[MPR2:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 1
811*537b16e9SGeorge Rokos   // CK3-DAG: [[CBP2:%.+]] = bitcast i8** [[BP2]] to %class.B**
812*537b16e9SGeorge Rokos   // CK3-DAG: [[CP2:%.+]] = bitcast i8** [[P2]] to %class.C**
813*537b16e9SGeorge Rokos   // CK3-DAG: store %class.B* [[BVAL]], %class.B** [[CBP2]]
814*537b16e9SGeorge Rokos   // CK3-DAG: store %class.C* [[BC]], %class.C** [[CP2]]
815*537b16e9SGeorge Rokos   // CK3-64-DAG: store i64 16, i64* [[S2]]
816*537b16e9SGeorge Rokos   // CK3-32-DAG: store i64 8, i64* [[S2]]
817*537b16e9SGeorge Rokos   // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR2]]
818*537b16e9SGeorge Rokos   // CK3-DAG: [[BP3:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 2
819*537b16e9SGeorge Rokos   // CK3-DAG: [[P3:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 2
820*537b16e9SGeorge Rokos   // CK3-DAG: [[S3:%.+]] = getelementptr inbounds {{.+}}[[SIZES]], i32 0, i32 2
821*537b16e9SGeorge Rokos   // CK3-DAG: [[MPR3:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 2
822*537b16e9SGeorge Rokos   // CK3-DAG: [[CBP3:%.+]] = bitcast i8** [[BP3]] to [10 x %class.C]**
823*537b16e9SGeorge Rokos   // CK3-DAG: [[CP3:%.+]] = bitcast i8** [[P3]] to %class.C**
824*537b16e9SGeorge Rokos   // CK3-DAG: store [10 x %class.C]* [[CVAL]], [10 x %class.C]** [[CBP3]]
825*537b16e9SGeorge Rokos   // CK3-DAG: [[CVALGEP:%.+]] = getelementptr inbounds {{.+}}[[CVAL]], i{{64|32}} 0, i{{64|32}} 0
826*537b16e9SGeorge Rokos   // CK3-DAG: store %class.C* [[CVALGEP]], %class.C** [[CP3]]
827*537b16e9SGeorge Rokos   // CK3-64-DAG: store i64 160, i64* [[S3]]
828*537b16e9SGeorge Rokos   // CK3-32-DAG: store i64 80, i64* [[S3]]
829*537b16e9SGeorge Rokos   // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR3]]
830*537b16e9SGeorge Rokos   // CK3: call void [[KERNEL:@.+]](%class.B* [[BVAL]], [10 x %class.C]* [[CVAL]])
831*537b16e9SGeorge Rokos   #pragma omp target map(mapper(id),tofrom: c[0:10], b.c)
832*537b16e9SGeorge Rokos   for (int i = 0; i < 10; i++) {
833*537b16e9SGeorge Rokos     b.c.a += ++c[i].a;
834*537b16e9SGeorge Rokos   }
835*537b16e9SGeorge Rokos }
836*537b16e9SGeorge Rokos 
837*537b16e9SGeorge Rokos 
838*537b16e9SGeorge Rokos // CK3: define internal void [[KERNEL]](%class.B* {{[^,]+}}, [10 x %class.C]* {{[^,]+}})
839*537b16e9SGeorge Rokos 
840*537b16e9SGeorge Rokos #endif // CK3
841*537b16e9SGeorge Rokos 
842*537b16e9SGeorge Rokos #endif // HEADER
843