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
23537b16e9SGeorge Rokos // Mapper function code generation and runtime interface.
24d47b9438SMichael Kruse 
25ebb1092aSShilei Tian // CK0: [[IDENT_T:%.+]] = type { i32, i32, i32, i32, i8* }
26ebb1092aSShilei Tian // CK0: [[ENTRY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
27ebb1092aSShilei Tian // CK0: [[ANON_T:%.+]] = type { %class.C* }
28ebb1092aSShilei Tian // CK0: [[ANON_T_0:%.+]] = type { %class.C* }
29ebb1092aSShilei Tian // CK0: [[KMP_TASK_T_WITH_PRIVATES:%.+]] = type { [[KMP_TASK_T:%[^,]+]], [[KMP_PRIVATES_T:%.+]] }
30ebb1092aSShilei Tian // CK0: [[KMP_TASK_T]] = type { i8*, i32 (i32, i8*)*, i32, %{{[^,]+}}, %{{[^,]+}} }
31ebb1092aSShilei Tian // CK0-32: [[KMP_PRIVATES_T]] = type { [1 x i64], [1 x i8*], [1 x i8*], [1 x i8*] }
32ebb1092aSShilei Tian // CK0-64: [[KMP_PRIVATES_T]] = type { [1 x i8*], [1 x i8*], [1 x i64], [1 x i8*] }
33ebb1092aSShilei Tian // CK0: [[KMP_TASK_T_WITH_PRIVATES_1:%.+]] = type { [[KMP_TASK_T]], [[KMP_PRIVATES_T_2:%.+]] }
34ebb1092aSShilei Tian // CK0-32: [[KMP_PRIVATES_T_2]] = type { [1 x i64], [1 x i8*], [1 x i8*], [1 x i8*] }
35ebb1092aSShilei Tian // CK0-64: [[KMP_PRIVATES_T_2]] = type { [1 x i8*], [1 x i8*], [1 x i64], [1 x i8*] }
360661328dSShilei Tian // CK0: [[KMP_TASK_T_WITH_PRIVATES_4:%.+]] = type { [[KMP_TASK_T]], [[KMP_PRIVATES_T_5:%.+]] }
370661328dSShilei Tian // CK0-32: [[KMP_PRIVATES_T_5]] = type { [1 x i64], [1 x i8*], [1 x i8*], [1 x i8*] }
380661328dSShilei Tian // CK0-64: [[KMP_PRIVATES_T_5]] = type { [1 x i8*], [1 x i8*], [1 x i64], [1 x i8*] }
390661328dSShilei Tian // CK0: [[KMP_TASK_T_WITH_PRIVATES_7:%.+]] = type { [[KMP_TASK_T]], [[KMP_PRIVATES_T_8:%.+]] }
400661328dSShilei Tian // CK0-32: [[KMP_PRIVATES_T_8]] = type { [1 x i64], [1 x i8*], [1 x i8*], [1 x i8*] }
410661328dSShilei Tian // CK0-64: [[KMP_PRIVATES_T_8]] = type { [1 x i8*], [1 x i8*], [1 x i64], [1 x i8*] }
420661328dSShilei Tian // CK0: [[KMP_TASK_T_WITH_PRIVATES_10:%.+]] = type { [[KMP_TASK_T]], [[KMP_PRIVATES_T_11:%.+]] }
430661328dSShilei Tian // CK0-32: [[KMP_PRIVATES_T_11]] = type { [1 x i64], [1 x i8*], [1 x i8*], [1 x i8*] }
440661328dSShilei Tian // CK0-64: [[KMP_PRIVATES_T_11]] = type { [1 x i8*], [1 x i8*], [1 x i64], [1 x i8*] }
45ebb1092aSShilei Tian 
46d47b9438SMichael Kruse // CK0-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}.region_id = weak constant i8 0
47d47b9438SMichael Kruse // CK0-64: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
48d47b9438SMichael Kruse // CK0-32: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
49d47b9438SMichael Kruse // CK0: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 35]
50537b16e9SGeorge Rokos // CK0-64: [[NWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
51537b16e9SGeorge Rokos // CK0-32: [[NWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
52537b16e9SGeorge Rokos // CK0: [[NWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 35]
53537b16e9SGeorge Rokos // CK0-64: [[TEAMSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
54537b16e9SGeorge Rokos // CK0-32: [[TEAMSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
55537b16e9SGeorge Rokos // CK0: [[TEAMTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
56537b16e9SGeorge Rokos // CK0-64: [[TEAMNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
57537b16e9SGeorge Rokos // CK0-32: [[TEAMNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
58537b16e9SGeorge Rokos // CK0: [[TEAMNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
59537b16e9SGeorge Rokos // CK0-64: [[EDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
60537b16e9SGeorge Rokos // CK0-32: [[EDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
61537b16e9SGeorge Rokos // CK0: [[EDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
62537b16e9SGeorge Rokos // CK0-64: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
63537b16e9SGeorge Rokos // CK0-32: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
64537b16e9SGeorge Rokos // CK0: [[EDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
65537b16e9SGeorge Rokos // CK0-64: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
66537b16e9SGeorge Rokos // CK0-32: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
67537b16e9SGeorge Rokos // CK0: [[EXDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
68537b16e9SGeorge Rokos // CK0-64: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
69537b16e9SGeorge Rokos // CK0-32: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
70537b16e9SGeorge Rokos // CK0: [[EXDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
71d47b9438SMichael Kruse // CK0-64: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
72d47b9438SMichael Kruse // CK0-32: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
73d47b9438SMichael Kruse // CK0: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33]
74d47b9438SMichael Kruse // CK0-64: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
75d47b9438SMichael Kruse // CK0-32: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
76d47b9438SMichael Kruse // CK0: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
77537b16e9SGeorge Rokos // CK0-64: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
78537b16e9SGeorge Rokos // CK0-32: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
79537b16e9SGeorge Rokos // CK0: [[FNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34]
80d47b9438SMichael Kruse 
814304e9d1SMichael Kruse class C {
824304e9d1SMichael Kruse public:
834304e9d1SMichael Kruse   int a;
84d47b9438SMichael Kruse   double *b;
854304e9d1SMichael Kruse };
864304e9d1SMichael Kruse 
87d47b9438SMichael Kruse #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
884304e9d1SMichael Kruse 
89537b16e9SGeorge Rokos // CK0: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
90d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
91d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
92d47b9438SMichael Kruse // CK0: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
93d47b9438SMichael Kruse // CK0: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
94d47b9438SMichael Kruse // CK0: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
95537b16e9SGeorge Rokos // CK0-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
96537b16e9SGeorge Rokos // CK0-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
97537b16e9SGeorge Rokos // CK0-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
98d47b9438SMichael Kruse // CK0-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
99d47b9438SMichael Kruse // CK0-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
100d47b9438SMichael Kruse // CK0-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
101d47b9438SMichael Kruse // CK0-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
102d47b9438SMichael Kruse // CK0-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
103d47b9438SMichael Kruse // CK0-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
104d47b9438SMichael Kruse // CK0: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
105d47b9438SMichael Kruse // CK0: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
1064304e9d1SMichael Kruse 
107d47b9438SMichael Kruse // CK0: [[INITEVALDEL]]
108d47b9438SMichael Kruse // CK0: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
109d47b9438SMichael Kruse // CK0: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
110d47b9438SMichael Kruse // CK0: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
111d47b9438SMichael Kruse // CK0: [[INIT]]
112d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
113d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
114d47b9438SMichael Kruse // CK0-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
115d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
116d47b9438SMichael Kruse // CK0: br label %[[LHEAD:[^,]+]]
1174304e9d1SMichael Kruse 
118d47b9438SMichael Kruse // CK0: [[LHEAD]]
119d47b9438SMichael Kruse // CK0: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
120d47b9438SMichael Kruse // CK0: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
121d47b9438SMichael Kruse // CK0: [[LBODY]]
122d47b9438SMichael Kruse // CK0: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
123d47b9438SMichael Kruse // CK0: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
124d47b9438SMichael Kruse // CK0-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 0
125d47b9438SMichael Kruse // CK0-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
126d47b9438SMichael Kruse // CK0-DAG: [[BBEGIN2:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
127d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGIN:%.+]] = load double*, double** [[BBEGIN2]]
128d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGINGEP:%.+]] = getelementptr inbounds double, double* [[BARRBEGIN]], i[[sz:64|32]] 0
129d47b9438SMichael Kruse // CK0-DAG: [[BEND:%.+]] = getelementptr double*, double** [[BBEGIN]], i32 1
130d47b9438SMichael Kruse // CK0-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
131d47b9438SMichael Kruse // CK0-DAG: [[BENDV:%.+]] = bitcast double** [[BEND]] to i8*
132d47b9438SMichael Kruse // CK0-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
133d47b9438SMichael Kruse // CK0-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
134d47b9438SMichael Kruse // CK0-DAG: [[CSIZE:%.+]] = sub i64 [[BENDI]], [[ABEGINI]]
135d47b9438SMichael Kruse // CK0-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
136d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
137d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
138d47b9438SMichael Kruse // CK0-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
139d47b9438SMichael Kruse // CK0-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
140d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
141d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
142d47b9438SMichael Kruse // CK0-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
143d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
144d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 32, [[SHIPRESIZE]]
145d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
146d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
147d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 32, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
148d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
149d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
150d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
151d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
152d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
153d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
154d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
155d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
156d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
157d47b9438SMichael Kruse // CK0-DAG: [[TO]]
158d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
159d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
160d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
161d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
162d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
163d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
164d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
165d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
166d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
167d47b9438SMichael Kruse // CK0-DAG: [[PHITYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
168d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[PHITYPE0]])
169d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
170d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
171d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
172d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
173d47b9438SMichael Kruse // CK0-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
174d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
175d47b9438SMichael Kruse // 281474976710659 == 0x1,000,000,003
176d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
177d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
178d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
179d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710659, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
180d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
181d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
182d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
183d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
184d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
185d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
186d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
187d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
188d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
189d47b9438SMichael Kruse // CK0-DAG: [[TO]]
190d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
191d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
192d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
193d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
194d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
195d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
196d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
197d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
198d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
199d47b9438SMichael Kruse // CK0-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
200d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]])
201d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR2BC:%.+]] = bitcast double** [[BBEGIN]] to i8*
202d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR2BC:%.+]] = bitcast double* [[BARRBEGINGEP]] to i8*
203d47b9438SMichael Kruse // CK0-DAG: br label %[[MEMBER:[^,]+]]
204d47b9438SMichael Kruse // CK0-DAG: [[MEMBER]]
205d47b9438SMichael Kruse // CK0-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
206d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOM]]
207d47b9438SMichael Kruse // 281474976710675 == 0x1,000,000,013
208d47b9438SMichael Kruse // CK0-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710675, [[SHIPRESIZE]]
209d47b9438SMichael Kruse // CK0-DAG: br label %[[LTYPE]]
210d47b9438SMichael Kruse // CK0-DAG: [[LTYPE]]
211d47b9438SMichael Kruse // CK0-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710675, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
212d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
213d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
214d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
215d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
216d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
217d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
218d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
219d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
220d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
221d47b9438SMichael Kruse // CK0-DAG: [[TO]]
222d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
223d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
224d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
225d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
226d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
227d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
228d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
229d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
230d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
231d47b9438SMichael Kruse // CK0-DAG: [[TYPE2:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
232d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR2BC]], i8* [[PTRADDR2BC]], i64 16, i64 [[TYPE2]])
233d47b9438SMichael Kruse // CK0: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
234d47b9438SMichael Kruse // CK0: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
235d47b9438SMichael Kruse // CK0: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
236d47b9438SMichael Kruse 
237d47b9438SMichael Kruse // CK0: [[LEXIT]]
238d47b9438SMichael Kruse // CK0: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
239d47b9438SMichael Kruse // CK0: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
240d47b9438SMichael Kruse // CK0: [[EVALDEL]]
241d47b9438SMichael Kruse // CK0: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
242d47b9438SMichael Kruse // CK0: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
243d47b9438SMichael Kruse // CK0: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
244d47b9438SMichael Kruse // CK0: [[DEL]]
245d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
246d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
247d47b9438SMichael Kruse // CK0-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
248d47b9438SMichael Kruse // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
249d47b9438SMichael Kruse // CK0: br label %[[DONE]]
250d47b9438SMichael Kruse // CK0: [[DONE]]
251d47b9438SMichael Kruse // CK0: ret void
252d47b9438SMichael Kruse 
253d47b9438SMichael Kruse 
254d47b9438SMichael Kruse // CK0-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
2554304e9d1SMichael Kruse void foo(int a){
2564304e9d1SMichael Kruse   int i = a;
2574304e9d1SMichael Kruse   C c;
2584304e9d1SMichael Kruse   c.a = a;
2594304e9d1SMichael Kruse 
260*da8bec47SJoseph Huber   // CK0-DAG: call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]])
261d47b9438SMichael Kruse   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
262d47b9438SMichael Kruse   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
263537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
264d47b9438SMichael Kruse   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
265d47b9438SMichael Kruse   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
266537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
267d47b9438SMichael Kruse   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
268d47b9438SMichael Kruse   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
269d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
270d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
271537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
272ebb1092aSShilei Tian   // CK0: call void [[KERNEL_1:@.+]](%class.C* [[VAL]])
2734304e9d1SMichael Kruse   #pragma omp target map(mapper(id),tofrom: c)
2744304e9d1SMichael Kruse   {
2754304e9d1SMichael Kruse     ++c.a;
2764304e9d1SMichael Kruse   }
27701f670dfSMichael Kruse 
278ebb1092aSShilei Tian   // CK0: [[BP2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_BP2:%[^,]+]], i32 0, i32 0
279ebb1092aSShilei Tian   // CK0: [[BP2CAST:%.+]] = bitcast i8** [[BP2GEP]] to %class.C**
280ebb1092aSShilei Tian   // CK0: store %class.C* [[CADDR:%[^,]+]], %class.C** [[BP2CAST]], align
281ebb1092aSShilei Tian   // CK0: [[P2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_P2:%[^,]+]], i32 0, i32 0
282ebb1092aSShilei Tian   // CK0: [[P2CAST:%.+]] = bitcast i8** [[P2GEP]] to %class.C**
283ebb1092aSShilei Tian   // CK0: store %class.C* [[CADDR]], %class.C** [[P2CAST]], align
284ebb1092aSShilei Tian   // CK0: [[MAPPER2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_MAPPER2:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
285ebb1092aSShilei Tian   // CK0: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MAPPER2GEP]], align
286ebb1092aSShilei Tian   // CK0: [[BP2:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_BP2]], i32 0, i32 0
287ebb1092aSShilei Tian   // CK0: [[P2:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_P2]], i32 0, i32 0
288ebb1092aSShilei Tian   // CK0: [[MAPPER2:%.+]] = bitcast [1 x i8*]* [[OFFLOAD_MAPPER2]] to i8**
289ebb1092aSShilei Tian   // CK0-32: [[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* {{@.+}}, i32 {{%.+}}, i32 1, i32 40, i32 4, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
290ebb1092aSShilei Tian   // CK0-64: [[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* {{@.+}}, i32 {{%.+}}, i32 1, i64 72, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[TASK_ENTRY:@.+]] to i32 (i32, i8*)*), i64 -1)
291ebb1092aSShilei Tian   // CK0: [[TASK_CAST:%.+]] = bitcast i8* [[TASK]] to [[KMP_TASK_T_WITH_PRIVATES]]*
292ebb1092aSShilei Tian   // CK0: [[TASK_WITH_PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_CAST]], i32 0, i32 1
293ebb1092aSShilei Tian   // CK0: {{.+}} = call i32 @__kmpc_omp_task([[IDENT_T]]* @1, i32 {{.+}}, i8* [[TASK]])
294537b16e9SGeorge Rokos   #pragma omp target map(mapper(id),tofrom: c) nowait
295537b16e9SGeorge Rokos   {
296537b16e9SGeorge Rokos     ++c.a;
297537b16e9SGeorge Rokos   }
298537b16e9SGeorge Rokos 
299*da8bec47SJoseph Huber   // CK0-DAG: call i32 @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[TEAMSIZES]]{{.+}}, {{.+}}[[TEAMTYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]], i32 0, i32 0)
300537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
301537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
302537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
303537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
304537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
305537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
306537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
307537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
308537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
309537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
310537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
311ebb1092aSShilei Tian   // CK0: call void [[KERNEL_3:@.+]](%class.C* [[VAL]])
312537b16e9SGeorge Rokos   #pragma omp target teams map(mapper(id),to: c)
313537b16e9SGeorge Rokos   {
314537b16e9SGeorge Rokos     ++c.a;
315537b16e9SGeorge Rokos   }
316537b16e9SGeorge Rokos 
317ebb1092aSShilei Tian   // CK0-32: [[TASK_1:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* {{@.+}}, i32 {{%.+}}, i32 1, i32 40, i32 4, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES_1]]*)* [[TASK_ENTRY_1:@.+]] to i32 (i32, i8*)*), i64 -1)
318ebb1092aSShilei Tian   // CK0-64: [[TASK_1:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* {{@.+}}, i32 {{%.+}}, i32 1, i64 72, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES_1]]*)* [[TASK_ENTRY_1:@.+]] to i32 (i32, i8*)*), i64 -1)
319ebb1092aSShilei Tian   // CK0: [[TASK_CAST_1:%.+]] = bitcast i8* [[TASK_1]] to [[KMP_TASK_T_WITH_PRIVATES_1]]*
320ebb1092aSShilei Tian   // CK0: [[TASK_CAST_GET_1:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_1]], [[KMP_TASK_T_WITH_PRIVATES_1]]* [[TASK_CAST_1]], i32 0, i32 0
321ebb1092aSShilei Tian   // CK0: {{.+}} = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASK_CAST_GET_1]], i32 0, i32 0
322ebb1092aSShilei Tian   // CK0: {{.+}} = call i32 @__kmpc_omp_task([[IDENT_T]]* @1, i32 {{.+}}, i8* [[TASK_1]])
323537b16e9SGeorge Rokos   #pragma omp target teams map(mapper(id),to: c) nowait
324537b16e9SGeorge Rokos   {
325537b16e9SGeorge Rokos     ++c.a;
326537b16e9SGeorge Rokos   }
327537b16e9SGeorge Rokos 
328*da8bec47SJoseph Huber   // CK0-DAG: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EDSIZES]]{{.+}}, {{.+}}[[EDTYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]])
329537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
330537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
331537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
332537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
333537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
334537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
335537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
336537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
337537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
338537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
339537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
340537b16e9SGeorge Rokos   #pragma omp target enter data map(mapper(id),to: c)
341537b16e9SGeorge Rokos 
3420661328dSShilei Tian   // CK0-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK_2:%.+]])
3430661328dSShilei Tian   // CK0-DAG: [[TASK_2]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i[[sz]] {{40|72}}, i[[sz]] 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES_4]]*)* [[OMP_TASK_ENTRY_18:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
3440661328dSShilei Tian   // CK0-DAG: [[TASK_WITH_PRIVATES:%.+]] = bitcast i8* [[TASK_2]] to [[KMP_TASK_T_WITH_PRIVATES_4]]*
3450661328dSShilei Tian   // CK0-DAG: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_4]], [[KMP_TASK_T_WITH_PRIVATES_4]]* [[TASK_WITH_PRIVATES]], i32 0, i32 1
3460661328dSShilei Tian   // CK0-32-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 1
3470661328dSShilei Tian   // CK0-64-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 0
3480661328dSShilei Tian   // CK0-DAG: [[FPBPADDR:%.+]] = bitcast [1 x i8*]* [[FPBPGEP]] to i8*
3490661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP:%.+]] to i8*
3500661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPBPADDR]], i8* align {{4|8}} [[BPADDR]], i[[sz]] {{4|8}}, i1 false)
3510661328dSShilei Tian   // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP:%.+]], i32 0, i32 0
3520661328dSShilei Tian   // CK0-DAG: [[BPGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP]], i32 0, i32 0
3530661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP]] to %class.C**
3540661328dSShilei Tian   // CK0-DAG: store %class.C* [[C:%[^,]+]], %class.C** [[BPADDR]], align
3550661328dSShilei Tian   // CK0-32-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 2
3560661328dSShilei Tian   // CK0-64-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 1
3570661328dSShilei Tian   // CK0-DAG: [[FPPADDR:%.+]] = bitcast [1 x i8*]* [[FPPGEP]] to i8*
3580661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP:%.+]] to i8*
3590661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPPADDR]], i8* align {{4|8}} [[PADDR]], i[[sz]] {{4|8}}, i1 false)
3600661328dSShilei Tian   // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P:%.+]], i32 0, i32 0
3610661328dSShilei Tian   // CK0-DAG: [[PGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P]], i32 0, i32 0
3620661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP]] to %class.C**
3630661328dSShilei Tian   // CK0-DAG: store %class.C* [[C]], %class.C** [[PADDR]], align
3640661328dSShilei Tian   // CK0-32-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 0
3650661328dSShilei Tian   // CK0-64-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 2
3660661328dSShilei Tian   // CK0-DAG: [[FPSZADDR:%.+]] = bitcast [1 x i64]* [[FPSZGEP]] to i8*
3670661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPSZADDR]], i8* align {{4|8}} bitcast ([1 x i64]* [[EDNWSIZES]] to i8*), i[[sz]] {{4|8}}, i1 false)
3680661328dSShilei Tian   // CK0-DAG: [[FPMPRGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_5]], [[KMP_PRIVATES_T_5]]* [[PRIVATES]], i32 0, i32 3
3690661328dSShilei Tian   // CK0-DAG: [[FPMPRADDR:%.+]] = bitcast [1 x i8*]* [[FPMPRGEP]] to i8*
3700661328dSShilei Tian   // CK0-DAG: [[MPRADDR:%.+]] = bitcast i8** [[MPRGEP:%.+]] to i8*
3710661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPMPRADDR]], i8* align {{4|8}} [[MPRADDR]], i[[sz]] {{4|8}}, i1 false)
3720661328dSShilei Tian   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%.+]] to i8**
3730661328dSShilei Tian   // CK0-DAG: [[MPRGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPR]], i[[sz]] 0, i[[sz]] 0
3740661328dSShilei Tian   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPRGEP]], align
375537b16e9SGeorge Rokos   #pragma omp target enter data map(mapper(id),to: c) nowait
376537b16e9SGeorge Rokos 
377*da8bec47SJoseph Huber   // CK0-DAG: call void @__tgt_target_data_end_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[EXDSIZES]]{{.+}}, {{.+}}[[EXDTYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]])
378537b16e9SGeorge Rokos   // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
379537b16e9SGeorge Rokos   // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
380537b16e9SGeorge Rokos   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
381537b16e9SGeorge Rokos   // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
382537b16e9SGeorge Rokos   // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
383537b16e9SGeorge Rokos   // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
384537b16e9SGeorge Rokos   // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
385537b16e9SGeorge Rokos   // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
386537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
387537b16e9SGeorge Rokos   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
388537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
389537b16e9SGeorge Rokos   #pragma omp target exit data map(mapper(id),from: c)
390537b16e9SGeorge Rokos 
3910661328dSShilei Tian   // CK0-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK_3:%.+]])
3920661328dSShilei Tian   // CK0-DAG: [[TASK_3]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i[[sz]] {{40|72}}, i[[sz]] 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES_7]]*)* [[OMP_TASK_ENTRY_25:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
3930661328dSShilei Tian   // CK0-DAG: [[TASK_WITH_PRIVATES:%.+]] = bitcast i8* [[TASK_3]] to [[KMP_TASK_T_WITH_PRIVATES_7]]*
3940661328dSShilei Tian   // CK0-DAG: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_7]], [[KMP_TASK_T_WITH_PRIVATES_7]]* [[TASK_WITH_PRIVATES]], i32 0, i32 1
3950661328dSShilei Tian   // CK0-32-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 1
3960661328dSShilei Tian   // CK0-64-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 0
3970661328dSShilei Tian   // CK0-DAG: [[FPBPADDR:%.+]] = bitcast [1 x i8*]* [[FPBPGEP]] to i8*
3980661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP:%.+]] to i8*
3990661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPBPADDR]], i8* align {{4|8}} [[BPADDR]], i[[sz]] {{4|8}}, i1 false)
4000661328dSShilei Tian   // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP:%.+]], i32 0, i32 0
4010661328dSShilei Tian   // CK0-DAG: [[BPGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP]], i32 0, i32 0
4020661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP]] to %class.C**
4030661328dSShilei Tian   // CK0-DAG: store %class.C* [[C:%[^,]+]], %class.C** [[BPADDR]], align
4040661328dSShilei Tian   // CK0-32-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 2
4050661328dSShilei Tian   // CK0-64-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 1
4060661328dSShilei Tian   // CK0-DAG: [[FPPADDR:%.+]] = bitcast [1 x i8*]* [[FPPGEP]] to i8*
4070661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP:%.+]] to i8*
4080661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPPADDR]], i8* align {{4|8}} [[PADDR]], i[[sz]] {{4|8}}, i1 false)
4090661328dSShilei Tian   // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P:%.+]], i32 0, i32 0
4100661328dSShilei Tian   // CK0-DAG: [[PGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P]], i32 0, i32 0
4110661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP]] to %class.C**
4120661328dSShilei Tian   // CK0-DAG: store %class.C* [[C]], %class.C** [[PADDR]], align
4130661328dSShilei Tian   // CK0-32-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 0
4140661328dSShilei Tian   // CK0-64-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 2
4150661328dSShilei Tian   // CK0-DAG: [[FPSZADDR:%.+]] = bitcast [1 x i64]* [[FPSZGEP]] to i8*
4160661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPSZADDR]], i8* align {{4|8}} bitcast ([1 x i64]* [[EXDNWSIZES]] to i8*), i[[sz]] {{4|8}}, i1 false)
4170661328dSShilei Tian   // CK0-DAG: [[FPMPRGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_8]], [[KMP_PRIVATES_T_8]]* [[PRIVATES]], i32 0, i32 3
4180661328dSShilei Tian   // CK0-DAG: [[FPMPRADDR:%.+]] = bitcast [1 x i8*]* [[FPMPRGEP]] to i8*
4190661328dSShilei Tian   // CK0-DAG: [[MPRADDR:%.+]] = bitcast i8** [[MPRGEP:%.+]] to i8*
4200661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPMPRADDR]], i8* align {{4|8}} [[MPRADDR]], i[[sz]] {{4|8}}, i1 false)
4210661328dSShilei Tian   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%.+]] to i8**
4220661328dSShilei Tian   // CK0-DAG: [[MPRGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPR]], i[[sz]] 0, i[[sz]] 0
4230661328dSShilei Tian   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPRGEP]], align
424537b16e9SGeorge Rokos   #pragma omp target exit data map(mapper(id),from: c) nowait
425537b16e9SGeorge Rokos 
426*da8bec47SJoseph Huber   // CK0-DAG: call void @__tgt_target_data_update_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[TGEPBP:%.+]], i8** [[TGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[TSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[TTYPES]]{{.+}}, i8** null, i8** [[TMPRGEP:%.+]])
427d47b9438SMichael Kruse   // CK0-DAG: [[TGEPBP]] = getelementptr inbounds {{.+}}[[TBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
428d47b9438SMichael Kruse   // CK0-DAG: [[TGEPP]] = getelementptr inbounds {{.+}}[[TP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
429537b16e9SGeorge Rokos   // CK0-DAG: [[TMPRGEP]] = bitcast [1 x i8*]* [[TMPR:%[^,]+]] to i8**
430d47b9438SMichael Kruse   // CK0-DAG: [[TBP0:%.+]] = getelementptr inbounds {{.+}}[[TBP]], i{{.+}} 0, i{{.+}} 0
431d47b9438SMichael Kruse   // CK0-DAG: [[TP0:%.+]] = getelementptr inbounds {{.+}}[[TP]], i{{.+}} 0, i{{.+}} 0
432537b16e9SGeorge Rokos   // CK0-DAG: [[TMPR1:%.+]] = getelementptr inbounds {{.+}}[[TMPR]], i[[sz]] 0, i[[sz]] 0
433d47b9438SMichael Kruse   // CK0-DAG: [[TCBP0:%.+]] = bitcast i8** [[TBP0]] to %class.C**
434d47b9438SMichael Kruse   // CK0-DAG: [[TCP0:%.+]] = bitcast i8** [[TP0]] to %class.C**
435d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[TCBP0]]
436d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[TCP0]]
437537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[TMPR1]]
43801f670dfSMichael Kruse   #pragma omp target update to(mapper(id): c)
4390336c75cSMichael Kruse 
440*da8bec47SJoseph Huber   // CK0-DAG: call void @__tgt_target_data_update_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[FGEPBP:%.+]], i8** [[FGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[FSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[FTYPES]]{{.+}}, i8** null, i8** [[FMPRGEP:%.+]])
441d47b9438SMichael Kruse   // CK0-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
442d47b9438SMichael Kruse   // CK0-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
443537b16e9SGeorge Rokos   // CK0-DAG: [[FMPRGEP]] = bitcast [1 x i8*]* [[FMPR:%[^,]+]] to i8**
444d47b9438SMichael Kruse   // CK0-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0
445d47b9438SMichael Kruse   // CK0-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0
446537b16e9SGeorge Rokos   // CK0-DAG: [[FMPR1:%.+]] = getelementptr inbounds {{.+}}[[FMPR]], i[[sz]] 0, i[[sz]] 0
447d47b9438SMichael Kruse   // CK0-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C**
448d47b9438SMichael Kruse   // CK0-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C**
449d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]]
450d47b9438SMichael Kruse   // CK0-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]]
451537b16e9SGeorge Rokos   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[FMPR1]]
4520336c75cSMichael Kruse   #pragma omp target update from(mapper(id): c)
453537b16e9SGeorge Rokos 
4540661328dSShilei Tian   // CK0-DAG: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i8* [[TASK_4:%.+]])
4550661328dSShilei Tian   // CK0-DAG: [[TASK_4]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i[[sz]] {{40|72}}, i[[sz]] 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES_10]]*)* [[OMP_TASK_ENTRY_34:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
4560661328dSShilei Tian   // CK0-DAG: [[TASK_WITH_PRIVATES:%.+]] = bitcast i8* [[TASK_4]] to [[KMP_TASK_T_WITH_PRIVATES_10]]*
4570661328dSShilei Tian   // CK0-DAG: [[PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_10]], [[KMP_TASK_T_WITH_PRIVATES_10]]* [[TASK_WITH_PRIVATES]], i32 0, i32 1
4580661328dSShilei Tian   // CK0-32-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 1
4590661328dSShilei Tian   // CK0-64-DAG: [[FPBPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 0
4600661328dSShilei Tian   // CK0-DAG: [[FPBPADDR:%.+]] = bitcast [1 x i8*]* [[FPBPGEP]] to i8*
4610661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP:%.+]] to i8*
4620661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPBPADDR]], i8* align {{4|8}} [[BPADDR]], i[[sz]] {{4|8}}, i1 false)
4630661328dSShilei Tian   // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP:%.+]], i32 0, i32 0
4640661328dSShilei Tian   // CK0-DAG: [[BPGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP]], i32 0, i32 0
4650661328dSShilei Tian   // CK0-DAG: [[BPADDR:%.+]] = bitcast i8** [[BPGEP]] to %class.C**
4660661328dSShilei Tian   // CK0-DAG: store %class.C* [[C:%[^,]+]], %class.C** [[BPADDR]], align
4670661328dSShilei Tian   // CK0-32-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 2
4680661328dSShilei Tian   // CK0-64-DAG: [[FPPGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 1
4690661328dSShilei Tian   // CK0-DAG: [[FPPADDR:%.+]] = bitcast [1 x i8*]* [[FPPGEP]] to i8*
4700661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP:%.+]] to i8*
4710661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPPADDR]], i8* align {{4|8}} [[PADDR]], i[[sz]] {{4|8}}, i1 false)
4720661328dSShilei Tian   // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P:%.+]], i32 0, i32 0
4730661328dSShilei Tian   // CK0-DAG: [[PGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P]], i32 0, i32 0
4740661328dSShilei Tian   // CK0-DAG: [[PADDR:%.+]] = bitcast i8** [[PGEP]] to %class.C**
4750661328dSShilei Tian   // CK0-DAG: store %class.C* [[C]], %class.C** [[PADDR]], align
4760661328dSShilei Tian   // CK0-32-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 0
4770661328dSShilei Tian   // CK0-64-DAG: [[FPSZGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 2
4780661328dSShilei Tian   // CK0-DAG: [[FPSZADDR:%.+]] = bitcast [1 x i64]* [[FPSZGEP]] to i8*
4790661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPSZADDR]], i8* align {{4|8}} bitcast ([1 x i64]* [[FNWSIZES]] to i8*), i[[sz]] {{4|8}}, i1 false)
4800661328dSShilei Tian   // CK0-DAG: [[FPMPRGEP:%.+]] = getelementptr inbounds [[KMP_PRIVATES_T_11]], [[KMP_PRIVATES_T_11]]* [[PRIVATES]], i32 0, i32 3
4810661328dSShilei Tian   // CK0-DAG: [[FPMPRADDR:%.+]] = bitcast [1 x i8*]* [[FPMPRGEP]] to i8*
4820661328dSShilei Tian   // CK0-DAG: [[MPRADDR:%.+]] = bitcast i8** [[MPRGEP:%.+]] to i8*
4830661328dSShilei Tian   // CK0-DAG: call void @llvm.memcpy.p0i8.p0i8.i[[sz]](i8* align {{4|8}} [[FPMPRADDR]], i8* align {{4|8}} [[MPRADDR]], i[[sz]] {{4|8}}, i1 false)
4840661328dSShilei Tian   // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%.+]] to i8**
4850661328dSShilei Tian   // CK0-DAG: [[MPRGEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPR]], i[[sz]] 0, i[[sz]] 0
4860661328dSShilei Tian   // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPRGEP]], align
487537b16e9SGeorge Rokos   #pragma omp target update from(mapper(id): c) nowait
4884304e9d1SMichael Kruse }
4894304e9d1SMichael Kruse 
4904304e9d1SMichael Kruse 
491ebb1092aSShilei Tian // CK0: define internal void [[KERNEL_1]](%class.C* {{.+}}[[ARG:%.+]])
492d47b9438SMichael Kruse // CK0: [[ADDR:%.+]] = alloca %class.C*,
493d47b9438SMichael Kruse // CK0: store %class.C* [[ARG]], %class.C** [[ADDR]]
494d47b9438SMichael Kruse // CK0: [[CADDR:%.+]] = load %class.C*, %class.C** [[ADDR]]
495d47b9438SMichael Kruse // CK0: [[CAADDR:%.+]] = getelementptr inbounds %class.C, %class.C* [[CADDR]], i32 0, i32 0
496d47b9438SMichael Kruse // CK0: [[VAL:%[^,]+]] = load i32, i32* [[CAADDR]]
497d47b9438SMichael Kruse // CK0: {{.+}} = add nsw i32 [[VAL]], 1
498d47b9438SMichael Kruse // CK0: }
499d47b9438SMichael Kruse 
500ebb1092aSShilei Tian // CK0: define internal void [[KERNEL_2:@.+]](%class.C* {{.+}}[[ARG:%.+]])
501ebb1092aSShilei Tian // CK0: [[ADDR:%.+]] = alloca %class.C*,
502ebb1092aSShilei Tian // CK0: store %class.C* [[ARG]], %class.C** [[ADDR]]
503ebb1092aSShilei Tian // CK0: [[CADDR:%.+]] = load %class.C*, %class.C** [[ADDR]]
504ebb1092aSShilei Tian // CK0: [[CAADDR:%.+]] = getelementptr inbounds %class.C, %class.C* [[CADDR]], i32 0, i32 0
505ebb1092aSShilei Tian // CK0: [[VAL:%[^,]+]] = load i32, i32* [[CAADDR]]
506ebb1092aSShilei Tian // CK0: {{.+}} = add nsw i32 [[VAL]], 1
507ebb1092aSShilei Tian // CK0: }
508ebb1092aSShilei Tian 
509ebb1092aSShilei Tian // CK0: define internal void [[OUTLINED:@.+]](i32 {{.*}}{{[^,]+}}, [[ANON_T]]* noalias [[CTXARG:%.+]])
510*da8bec47SJoseph Huber // CK0-DAG: call i32 @__tgt_target_nowait_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZEGEP:%[0-9]+]], {{.+}}[[NWTYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]])
511ebb1092aSShilei Tian // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
512ebb1092aSShilei Tian // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
513ebb1092aSShilei Tian // CK0-DAG: [[SIZEGEP]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SIZEFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
514ebb1092aSShilei Tian // CK0-DAG: [[MPRGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
515ebb1092aSShilei Tian // CK0-DAG: [[BPFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_BP:%.+]], align
516ebb1092aSShilei Tian // CK0-DAG: [[PFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_P:%.+]], align
517ebb1092aSShilei Tian // CK0-DAG: [[SIZEFPADDR]] = load [1 x i64]*, [1 x i64]** [[FPPTRADDR_SIZE:%.+]], align
518ebb1092aSShilei Tian // CK0-DAG: [[MPRFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_MPR:%.+]], align
519ebb1092aSShilei Tian // CK0-DAG: call void (i8*, ...) %1(i8* %2, {{.+}}[[FPPTRADDR_BP]], {{.+}}[[FPPTRADDR_P]], {{.+}}[[FPPTRADDR_SIZE]], {{.+}}[[FPPTRADDR_MPR]])
520ebb1092aSShilei Tian // CK0-DAG: call void [[KERNEL_2:@.+]](%class.C* [[KERNELARG:%.+]])
521ebb1092aSShilei Tian // CK0-DAG: [[KERNELARG]] = load %class.C*, %class.C** [[KERNELARGGEP:%.+]], align
522ebb1092aSShilei Tian // CK0-DAG: [[KERNELARGGEP]] = getelementptr inbounds [[ANON_T]], [[ANON_T]]* [[CTX:%.+]], i32 0, i32 0
523ebb1092aSShilei Tian // CK0-DAG: [[CTX]] = load [[ANON_T]]*, [[ANON_T]]** [[CTXADDR:%.+]], align
524ebb1092aSShilei Tian // CK0-DAG: store [[ANON_T]]* [[CTXARG]], [[ANON_T]]** [[CTXADDR]], align
525ebb1092aSShilei Tian // CK0: }
526ebb1092aSShilei Tian 
527ebb1092aSShilei Tian // CK0: define internal {{.*}}i32 [[TASK_ENTRY]](i32 {{.*}}%0, [[KMP_TASK_T_WITH_PRIVATES]]* noalias %1)
528ebb1092aSShilei Tian // CK0: store [[KMP_TASK_T_WITH_PRIVATES]]* %1, [[KMP_TASK_T_WITH_PRIVATES]]** [[ADDR:%.+]], align
529ebb1092aSShilei Tian // CK0: [[TASK_T_WITH_PRIVATES:%.+]] = load [[KMP_TASK_T_WITH_PRIVATES]]*, [[KMP_TASK_T_WITH_PRIVATES]]** [[ADDR]], align
530ebb1092aSShilei Tian // CK0: [[TASKGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 0
531ebb1092aSShilei Tian // CK0: [[SHAREDSGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASKGEP]], i32 0, i32 0
532ebb1092aSShilei Tian // CK0: [[SHAREDS:%.+]] = load i8*, i8** [[SHAREDSGEP]], align
533ebb1092aSShilei Tian // CK0: [[ANON:%.+]] = bitcast i8* [[SHAREDS]] to [[ANON_T]]*
534ebb1092aSShilei Tian // CK0: [[PRIVATESGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 1
535ebb1092aSShilei Tian // CK0: [[PRIVATES:%.+]] = bitcast [[KMP_PRIVATES_T]]* [[PRIVATESGEP]] to i8*
536ebb1092aSShilei Tian // CK0: [[TASK_WITH_PRIVATES:%.+]] = bitcast [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]] to i8*
537ebb1092aSShilei Tian // CK0: call void [[OUTLINED]](i32 {{%.+}}, i32* {{%.+}}, i8* [[PRIVATES]], {{.+}}, i8* [[TASK_WITH_PRIVATES]], [[ANON_T]]* [[ANON]])
538ebb1092aSShilei Tian // CK0: }
539ebb1092aSShilei Tian 
540ebb1092aSShilei Tian // CK0: define internal void [[OUTLINE_1:@.+]](i32 {{.*}}%.global_tid.{{.+}}, [[ANON_T_0]]* noalias [[CTXARG:%.+]])
541*da8bec47SJoseph Huber // CK0-DAG: call i32 @__tgt_target_teams_nowait_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], i64* [[SIZEGEP:%[0-9]+]], {{.+}}[[TEAMNWTYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]], i32 0, i32 0)
542ebb1092aSShilei Tian // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
543ebb1092aSShilei Tian // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
544ebb1092aSShilei Tian // CK0-DAG: [[SIZEGEP]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SIZEFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
545ebb1092aSShilei Tian // CK0-DAG: [[MPRGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
546ebb1092aSShilei Tian // CK0-DAG: [[BPFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_BP:%.+]], align
547ebb1092aSShilei Tian // CK0-DAG: [[PFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_P:%.+]], align
548ebb1092aSShilei Tian // CK0-DAG: [[SIZEFPADDR]] = load [1 x i64]*, [1 x i64]** [[FPPTRADDR_SIZE:%.+]], align
549ebb1092aSShilei Tian // CK0-DAG: [[MPRFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_MPR:%.+]], align
550ebb1092aSShilei Tian // CK0-DAG: call void (i8*, ...) %1(i8* %2, {{.+}}[[FPPTRADDR_BP]], {{.+}}[[FPPTRADDR_P]], {{.+}}[[FPPTRADDR_SIZE]], {{.+}}[[FPPTRADDR_MPR]])
551ebb1092aSShilei Tian // CK0-DAG: call void [[KERNEL_2:@.+]](%class.C* [[KERNELARG:%.+]])
552ebb1092aSShilei Tian // CK0-DAG: [[KERNELARG]] = load %class.C*, %class.C** [[KERNELARGGEP:%.+]], align
553ebb1092aSShilei Tian // CK0-DAG: [[KERNELARGGEP]] = getelementptr inbounds [[ANON_T_0]], [[ANON_T_0]]* [[CTX:%.+]], i32 0, i32 0
554ebb1092aSShilei Tian // CK0-DAG: [[CTX]] = load [[ANON_T_0]]*, [[ANON_T_0]]** [[CTXADDR:%.+]], align
555ebb1092aSShilei Tian // CK0-DAG: store [[ANON_T_0]]* [[CTXARG]], [[ANON_T_0]]** [[CTXADDR]], align
556ebb1092aSShilei Tian // CK0: }
557ebb1092aSShilei Tian 
558ebb1092aSShilei Tian // CK0: define internal {{.*}}i32 [[TASK_ENTRY_1]](i32 {{.*}}%0, [[KMP_TASK_T_WITH_PRIVATES_1]]* noalias %1)
559ebb1092aSShilei Tian // CK0: store [[KMP_TASK_T_WITH_PRIVATES_1]]* %1, [[KMP_TASK_T_WITH_PRIVATES_1]]** [[ADDR:%.+]], align
560ebb1092aSShilei Tian // CK0: [[TASK_T_WITH_PRIVATES:%.+]] = load [[KMP_TASK_T_WITH_PRIVATES_1]]*, [[KMP_TASK_T_WITH_PRIVATES_1]]** [[ADDR]], align
561ebb1092aSShilei Tian // CK0: [[TASKGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_1]], [[KMP_TASK_T_WITH_PRIVATES_1]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 0
562ebb1092aSShilei Tian // CK0: [[SHAREDSGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASKGEP]], i32 0, i32 0
563ebb1092aSShilei Tian // CK0: [[SHAREDS:%.+]] = load i8*, i8** [[SHAREDSGEP]], align
564ebb1092aSShilei Tian // CK0: [[ANON:%.+]] = bitcast i8* [[SHAREDS]] to [[ANON_T_0]]*
565ebb1092aSShilei Tian // CK0: [[PRIVATESGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES_1]], [[KMP_TASK_T_WITH_PRIVATES_1]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 1
566ebb1092aSShilei Tian // CK0: [[PRIVATES:%.+]] = bitcast [[KMP_PRIVATES_T_2]]* [[PRIVATESGEP]] to i8*
567ebb1092aSShilei Tian // CK0: [[TASK_WITH_PRIVATES:%.+]] = bitcast [[KMP_TASK_T_WITH_PRIVATES_1]]* [[TASK_T_WITH_PRIVATES]] to i8*
568ebb1092aSShilei Tian // CK0: call void [[OUTLINE_1]](i32 {{%.+}}, i32* {{%.+}}, i8* [[PRIVATES]], {{.+}}, i8* [[TASK_WITH_PRIVATES]], [[ANON_T_0]]* [[ANON]])
569ebb1092aSShilei Tian // CK0: }
570ebb1092aSShilei Tian 
5710661328dSShilei Tian // CK0: define internal void [[OMP_OUTLINED_16:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias %{{[^,]+}}, i8* noalias %{{[^,]+}}
572*da8bec47SJoseph Huber // CK0-DAG: call void @__tgt_target_data_begin_nowait_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* [[SZ:%[^,]+]], i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[EDNWTYPES]], i32 0, i32 0), i8** null, i8** [[MPR:%.+]])
5730661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5740661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5750661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5760661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5770661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
5780661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
5790661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
5800661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
5810661328dSShilei Tian // CK0-DAG: call void (i8*, ...) %{{.+}}(i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
5820661328dSShilei Tian // CK0: ret void
5830661328dSShilei Tian // CK0: }
5840661328dSShilei Tian 
5850661328dSShilei Tian // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_18]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_4]]* noalias %{{[^,]+}})
5860661328dSShilei Tian // CK0:   call void [[OMP_OUTLINED_16]]
5870661328dSShilei Tian // CK0:   ret i32 0
5880661328dSShilei Tian // CK0: }
5890661328dSShilei Tian 
5900661328dSShilei Tian // CK0: define internal void [[OMP_OUTLINED_23:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias %{{[^,]+}}, i8* noalias %{{[^,]+}}
591*da8bec47SJoseph Huber // CK0-DAG: call void @__tgt_target_data_end_nowait_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* [[SZ:%[^,]+]], i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[EXDNWTYPES]], i32 0, i32 0), i8** null, i8** [[MPR:%.+]])
5920661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5930661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5940661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5950661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5960661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
5970661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
5980661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
5990661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
6000661328dSShilei Tian // CK0-DAG: call void (i8*, ...) %{{.+}}(i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
6010661328dSShilei Tian // CK0: }
6020661328dSShilei Tian 
6030661328dSShilei Tian // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_25]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_7]]* noalias %{{[^,]+}})
6040661328dSShilei Tian // CK0:   call void [[OMP_OUTLINED_23]]
6050661328dSShilei Tian // CK0:   ret i32 0
6060661328dSShilei Tian // CK0: }
6070661328dSShilei Tian 
6080661328dSShilei Tian // CK0: define internal void [[OMP_OUTLINED_32:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias %{{[^,]+}}, i8* noalias %{{[^,]+}}
609*da8bec47SJoseph Huber // CK0-DAG: call void @__tgt_target_data_update_nowait_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i64* [[SZ:%[^,]+]], i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[FNWTYPES]], i32 0, i32 0), i8** null, i8** [[MPR:%.+]])
6100661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6110661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6120661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6130661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6140661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
6150661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
6160661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
6170661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
6180661328dSShilei Tian // CK0-DAG: call void (i8*, ...) %{{.+}}(i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
6190661328dSShilei Tian // CK0: }
6200661328dSShilei Tian 
6210661328dSShilei Tian // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_34]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_10]]* noalias %{{[^,]+}})
6220661328dSShilei Tian // CK0:   call void [[OMP_OUTLINED_32]]
6230661328dSShilei Tian // CK0:   ret i32 0
6240661328dSShilei Tian // CK0: }
6250661328dSShilei Tian 
626537b16e9SGeorge Rokos #endif // CK0
627d47b9438SMichael Kruse 
628d47b9438SMichael Kruse 
629d47b9438SMichael Kruse ///==========================================================================///
630d47b9438SMichael 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
631d47b9438SMichael 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
632d47b9438SMichael 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
633d47b9438SMichael 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
634d47b9438SMichael 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
635d47b9438SMichael 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
636d47b9438SMichael Kruse 
637d47b9438SMichael 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
638d47b9438SMichael 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
639d47b9438SMichael 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
640d47b9438SMichael 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
641d47b9438SMichael 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
642d47b9438SMichael 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
643d47b9438SMichael Kruse 
644d47b9438SMichael Kruse #ifdef CK1
645537b16e9SGeorge Rokos // C++ template
646d47b9438SMichael Kruse 
647d47b9438SMichael Kruse template <class T>
648d47b9438SMichael Kruse class C {
649d47b9438SMichael Kruse public:
650d47b9438SMichael Kruse   T a;
651d47b9438SMichael Kruse };
652d47b9438SMichael Kruse 
653d47b9438SMichael Kruse #pragma omp declare mapper(id: C<int> s) map(s.a)
654d47b9438SMichael Kruse 
655d47b9438SMichael Kruse // CK1-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id{{.*}}(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
656d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
657d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
658d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
659d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
660d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
661537b16e9SGeorge Rokos // CK1-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
662537b16e9SGeorge Rokos // CK1-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 4
663d47b9438SMichael Kruse // CK1-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
664d47b9438SMichael Kruse // CK1-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
665d47b9438SMichael Kruse // CK1-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
666d47b9438SMichael Kruse // CK1-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
667d47b9438SMichael Kruse // CK1-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
668d47b9438SMichael Kruse // CK1-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
669d47b9438SMichael Kruse // CK1: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
670d47b9438SMichael Kruse // CK1: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
671d47b9438SMichael Kruse 
672d47b9438SMichael Kruse // CK1: [[INITEVALDEL]]
673d47b9438SMichael Kruse // CK1: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
674d47b9438SMichael Kruse // CK1: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
675d47b9438SMichael Kruse // CK1: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
676d47b9438SMichael Kruse // CK1: [[INIT]]
677d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
678d47b9438SMichael Kruse // CK1-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
679d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
680d47b9438SMichael Kruse // CK1: br label %[[LHEAD:[^,]+]]
681d47b9438SMichael Kruse 
682d47b9438SMichael Kruse // CK1: [[LHEAD]]
683d47b9438SMichael Kruse // CK1: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
684d47b9438SMichael Kruse // CK1: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
685d47b9438SMichael Kruse // CK1: [[LBODY]]
686d47b9438SMichael Kruse // CK1: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
687d47b9438SMichael Kruse // CK1: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
688d47b9438SMichael Kruse // CK1-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 0
689d47b9438SMichael Kruse // CK1-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
690d47b9438SMichael Kruse // CK1-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
691d47b9438SMichael Kruse // CK1-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
692d47b9438SMichael Kruse // CK1-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
693d47b9438SMichael Kruse // CK1-DAG: br label %[[MEMBER:[^,]+]]
694d47b9438SMichael Kruse // CK1-DAG: [[MEMBER]]
6955292187aSAlexey Bataev // CK1-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
696d47b9438SMichael Kruse // CK1-DAG: [[MEMBERCOM]]
6975292187aSAlexey Bataev // CK1-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 35, [[SHIPRESIZE]]
698d47b9438SMichael Kruse // CK1-DAG: br label %[[LTYPE]]
699d47b9438SMichael Kruse // CK1-DAG: [[LTYPE]]
7005292187aSAlexey Bataev // CK1-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 35, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
701d47b9438SMichael Kruse // CK1-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
702d47b9438SMichael Kruse // CK1-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
703d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
704d47b9438SMichael Kruse // CK1-DAG: [[ALLOC]]
705d47b9438SMichael Kruse // CK1-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
706d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND:[^,]+]]
707d47b9438SMichael Kruse // CK1-DAG: [[ALLOCELSE]]
708d47b9438SMichael Kruse // CK1-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
709d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
710d47b9438SMichael Kruse // CK1-DAG: [[TO]]
711d47b9438SMichael Kruse // CK1-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
712d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
713d47b9438SMichael Kruse // CK1-DAG: [[TOELSE]]
714d47b9438SMichael Kruse // CK1-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
715d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
716d47b9438SMichael Kruse // CK1-DAG: [[FROM]]
717d47b9438SMichael Kruse // CK1-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
718d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
719d47b9438SMichael Kruse // CK1-DAG: [[TYEND]]
720d47b9438SMichael Kruse // CK1-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
721d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]])
722d47b9438SMichael Kruse // CK1: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
723d47b9438SMichael Kruse // CK1: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
724d47b9438SMichael Kruse // CK1: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
725d47b9438SMichael Kruse 
726d47b9438SMichael Kruse // CK1: [[LEXIT]]
727d47b9438SMichael Kruse // CK1: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
728d47b9438SMichael Kruse // CK1: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
729d47b9438SMichael Kruse // CK1: [[EVALDEL]]
730d47b9438SMichael Kruse // CK1: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
731d47b9438SMichael Kruse // CK1: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
732d47b9438SMichael Kruse // CK1: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
733d47b9438SMichael Kruse // CK1: [[DEL]]
734d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
735d47b9438SMichael Kruse // CK1-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
736d47b9438SMichael Kruse // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
737d47b9438SMichael Kruse // CK1: br label %[[DONE]]
738d47b9438SMichael Kruse // CK1: [[DONE]]
739d47b9438SMichael Kruse // CK1: ret void
740d47b9438SMichael Kruse 
741537b16e9SGeorge Rokos #endif // CK1
7424304e9d1SMichael Kruse 
743537b16e9SGeorge Rokos 
744537b16e9SGeorge Rokos ///==========================================================================///
745537b16e9SGeorge 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
746537b16e9SGeorge 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
747537b16e9SGeorge 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
748537b16e9SGeorge 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
749537b16e9SGeorge 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
750537b16e9SGeorge 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
751537b16e9SGeorge Rokos 
752537b16e9SGeorge 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
753537b16e9SGeorge 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
754537b16e9SGeorge 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
755537b16e9SGeorge 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
756537b16e9SGeorge 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
757537b16e9SGeorge 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
758537b16e9SGeorge Rokos 
759537b16e9SGeorge Rokos #ifdef CK2
760537b16e9SGeorge Rokos // Nested mappers.
761537b16e9SGeorge Rokos 
762537b16e9SGeorge Rokos class B {
763537b16e9SGeorge Rokos public:
764537b16e9SGeorge Rokos   double a;
765537b16e9SGeorge Rokos };
766537b16e9SGeorge Rokos 
767537b16e9SGeorge Rokos class C {
768537b16e9SGeorge Rokos public:
769537b16e9SGeorge Rokos   double a;
770537b16e9SGeorge Rokos   B b;
771537b16e9SGeorge Rokos };
772537b16e9SGeorge Rokos 
773537b16e9SGeorge Rokos #pragma omp declare mapper(B s) map(s.a)
774537b16e9SGeorge Rokos 
775537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.b)
776537b16e9SGeorge Rokos 
777537b16e9SGeorge Rokos // CK2: define {{.*}}void [[BMPRFUNC:@[.]omp_mapper[.].*B[.]default]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
778537b16e9SGeorge Rokos 
779537b16e9SGeorge Rokos // CK2-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
780537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
781537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
782537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
783537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
784537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
785537b16e9SGeorge Rokos // CK2-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
786537b16e9SGeorge Rokos // CK2-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
787537b16e9SGeorge Rokos // CK2-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
788537b16e9SGeorge Rokos // CK2-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
789537b16e9SGeorge Rokos // CK2-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
790537b16e9SGeorge Rokos // CK2-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
791537b16e9SGeorge Rokos // CK2-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
792537b16e9SGeorge Rokos // CK2-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
793537b16e9SGeorge Rokos // CK2: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
794537b16e9SGeorge Rokos // CK2: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
795537b16e9SGeorge Rokos 
796537b16e9SGeorge Rokos // CK2: [[INITEVALDEL]]
797537b16e9SGeorge Rokos // CK2: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
798537b16e9SGeorge Rokos // CK2: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
799537b16e9SGeorge Rokos // CK2: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
800537b16e9SGeorge Rokos // CK2: [[INIT]]
801537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
802537b16e9SGeorge Rokos // CK2-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
803537b16e9SGeorge Rokos // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
804537b16e9SGeorge Rokos // CK2: br label %[[LHEAD:[^,]+]]
805537b16e9SGeorge Rokos 
806537b16e9SGeorge Rokos // CK2: [[LHEAD]]
807537b16e9SGeorge Rokos // CK2: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
808537b16e9SGeorge Rokos // CK2: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
809537b16e9SGeorge Rokos // CK2: [[LBODY]]
810537b16e9SGeorge Rokos // CK2: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
811537b16e9SGeorge Rokos // CK2: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
812537b16e9SGeorge Rokos // CK2-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
813537b16e9SGeorge Rokos // CK2-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
814537b16e9SGeorge Rokos // CK2-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
815537b16e9SGeorge Rokos // CK2-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
816537b16e9SGeorge Rokos // CK2-DAG: [[PTRADDR1BC:%.+]] = bitcast %class.B* [[BBEGIN]] to i8*
817537b16e9SGeorge Rokos // CK2-DAG: br label %[[MEMBER:[^,]+]]
818537b16e9SGeorge Rokos // CK2-DAG: [[MEMBER]]
8195292187aSAlexey Bataev // CK2-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
820537b16e9SGeorge Rokos // CK2-DAG: [[MEMBERCOM]]
8215292187aSAlexey Bataev // CK2-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 35, [[SHIPRESIZE]]
822537b16e9SGeorge Rokos // CK2-DAG: br label %[[LTYPE]]
823537b16e9SGeorge Rokos // CK2-DAG: [[LTYPE]]
8245292187aSAlexey Bataev // CK2-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 35, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
825537b16e9SGeorge Rokos // CK2-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
826537b16e9SGeorge Rokos // CK2-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
827537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
828537b16e9SGeorge Rokos // CK2-DAG: [[ALLOC]]
829537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
830537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND:[^,]+]]
831537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCELSE]]
832537b16e9SGeorge Rokos // CK2-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
833537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
834537b16e9SGeorge Rokos // CK2-DAG: [[TO]]
835537b16e9SGeorge Rokos // CK2-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
836537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
837537b16e9SGeorge Rokos // CK2-DAG: [[TOELSE]]
838537b16e9SGeorge Rokos // CK2-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
839537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
840537b16e9SGeorge Rokos // CK2-DAG: [[FROM]]
841537b16e9SGeorge Rokos // CK2-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
842537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
843537b16e9SGeorge Rokos // CK2-DAG: [[TYEND]]
844537b16e9SGeorge Rokos // CK2-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
845537b16e9SGeorge Rokos // CK2: call void [[BMPRFUNC]](i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 8, i64 [[TYPE1]])
846537b16e9SGeorge Rokos // CK2: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
847537b16e9SGeorge Rokos // CK2: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
848537b16e9SGeorge Rokos // CK2: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
849537b16e9SGeorge Rokos 
850537b16e9SGeorge Rokos // CK2: [[LEXIT]]
851537b16e9SGeorge Rokos // CK2: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
852537b16e9SGeorge Rokos // CK2: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
853537b16e9SGeorge Rokos // CK2: [[EVALDEL]]
854537b16e9SGeorge Rokos // CK2: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
855537b16e9SGeorge Rokos // CK2: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
856537b16e9SGeorge Rokos // CK2: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
857537b16e9SGeorge Rokos // CK2: [[DEL]]
858537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
859537b16e9SGeorge Rokos // CK2-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
860537b16e9SGeorge Rokos // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
861537b16e9SGeorge Rokos // CK2: br label %[[DONE]]
862537b16e9SGeorge Rokos // CK2: [[DONE]]
863537b16e9SGeorge Rokos // CK2: ret void
864537b16e9SGeorge Rokos 
865537b16e9SGeorge Rokos #endif // CK2
866537b16e9SGeorge Rokos 
867537b16e9SGeorge Rokos 
868537b16e9SGeorge Rokos ///==========================================================================///
869537b16e9SGeorge 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
870537b16e9SGeorge 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
871537b16e9SGeorge 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
872537b16e9SGeorge 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
873537b16e9SGeorge 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
874537b16e9SGeorge 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
875537b16e9SGeorge Rokos 
876537b16e9SGeorge 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
877537b16e9SGeorge 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
878537b16e9SGeorge 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
879537b16e9SGeorge 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
880537b16e9SGeorge 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
881537b16e9SGeorge 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
882537b16e9SGeorge Rokos 
883537b16e9SGeorge Rokos #ifdef CK3
884537b16e9SGeorge Rokos // map of array sections and nested components.
885537b16e9SGeorge Rokos 
886537b16e9SGeorge Rokos // CK3-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}.region_id = weak constant i8 0
8875292187aSAlexey Bataev // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [2 x i64] [i64 {{8|16}}, i64 {{80|160}}]
8885292187aSAlexey Bataev // CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [2 x i64] [i64 35, i64 35]
889537b16e9SGeorge Rokos 
890537b16e9SGeorge Rokos class C {
891537b16e9SGeorge Rokos public:
892537b16e9SGeorge Rokos   int a;
893537b16e9SGeorge Rokos   double *b;
894537b16e9SGeorge Rokos };
895537b16e9SGeorge Rokos 
896537b16e9SGeorge Rokos class B {
897537b16e9SGeorge Rokos public:
898537b16e9SGeorge Rokos   C c;
899537b16e9SGeorge Rokos };
900537b16e9SGeorge Rokos 
901537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
902537b16e9SGeorge Rokos 
903537b16e9SGeorge Rokos // CK3: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
904537b16e9SGeorge Rokos 
905537b16e9SGeorge Rokos // CK3-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
906537b16e9SGeorge Rokos void foo(int a){
907537b16e9SGeorge Rokos   // CK3-DAG: [[CVAL:%.+]] = alloca [10 x %class.C]
908537b16e9SGeorge Rokos   // CK3-DAG: [[BVAL:%.+]] = alloca %class.B
909537b16e9SGeorge Rokos   C c[10];
910537b16e9SGeorge Rokos   B b;
911537b16e9SGeorge Rokos 
912537b16e9SGeorge Rokos   // CK3-DAG: [[BC:%.+]] = getelementptr inbounds %class.B, %class.B* [[BVAL]], i32 0, i32 0
913537b16e9SGeorge Rokos 
914*da8bec47SJoseph Huber   // CK3-DAG: call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 {{.+}}, i8* {{.+}}, i32 2, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}}, i8** null, i8** [[MPRGEP:%.+]])
915537b16e9SGeorge Rokos   // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
916537b16e9SGeorge Rokos   // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
9175292187aSAlexey Bataev   // CK3-DAG: [[MPRGEP]] = bitcast [2 x i8*]* [[MPR:%[^,]+]] to i8**
918537b16e9SGeorge Rokos   // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
919537b16e9SGeorge Rokos   // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
920537b16e9SGeorge Rokos   // CK3-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 0
921537b16e9SGeorge Rokos   // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.B**
922537b16e9SGeorge Rokos   // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
923537b16e9SGeorge Rokos   // CK3-DAG: store %class.B* [[BVAL]], %class.B** [[CBP1]]
924537b16e9SGeorge Rokos   // CK3-DAG: store %class.C* [[BC]], %class.C** [[CP1]]
9255292187aSAlexey Bataev   // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
926537b16e9SGeorge Rokos   // CK3-DAG: [[BP2:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 1
927537b16e9SGeorge Rokos   // CK3-DAG: [[P2:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 1
928537b16e9SGeorge Rokos   // CK3-DAG: [[MPR2:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 1
9295292187aSAlexey Bataev   // CK3-DAG: [[CBP2:%.+]] = bitcast i8** [[BP2]] to [10 x %class.C]**
930537b16e9SGeorge Rokos   // CK3-DAG: [[CP2:%.+]] = bitcast i8** [[P2]] to %class.C**
9315292187aSAlexey Bataev   // CK3-DAG: store [10 x %class.C]* [[CVAL]], [10 x %class.C]** [[CBP2]]
932537b16e9SGeorge Rokos   // CK3-DAG: [[CVALGEP:%.+]] = getelementptr inbounds {{.+}}[[CVAL]], i{{64|32}} 0, i{{64|32}} 0
9335292187aSAlexey Bataev   // CK3-DAG: store %class.C* [[CVALGEP]], %class.C** [[CP2]]
9345292187aSAlexey Bataev   // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[MPR2]]
935537b16e9SGeorge Rokos   // CK3: call void [[KERNEL:@.+]](%class.B* [[BVAL]], [10 x %class.C]* [[CVAL]])
936537b16e9SGeorge Rokos   #pragma omp target map(mapper(id),tofrom: c[0:10], b.c)
937537b16e9SGeorge Rokos   for (int i = 0; i < 10; i++) {
938537b16e9SGeorge Rokos     b.c.a += ++c[i].a;
939537b16e9SGeorge Rokos   }
940537b16e9SGeorge Rokos }
941537b16e9SGeorge Rokos 
942537b16e9SGeorge Rokos 
943537b16e9SGeorge Rokos // CK3: define internal void [[KERNEL]](%class.B* {{[^,]+}}, [10 x %class.C]* {{[^,]+}})
944537b16e9SGeorge Rokos 
945537b16e9SGeorge Rokos #endif // CK3
946537b16e9SGeorge Rokos 
9479f2f3b9dSJoel E. Denny ///==========================================================================///
9489f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -verify -fopenmp -fopenmp-version=51 -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 CK4 --check-prefix CK4-64 %s
9499f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp -fopenmp-version=51 -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
9509f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp -fopenmp-version=51 -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 CK4 --check-prefix CK4-64 %s
9519f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -verify -fopenmp -fopenmp-version=51 -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 CK4 --check-prefix CK4-32 %s
9529f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp -fopenmp-version=51 -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
9539f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp -fopenmp-version=51 -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 CK4 --check-prefix CK4-32 %s
9549f2f3b9dSJoel E. Denny 
9559f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -verify -fopenmp-simd -fopenmp-version=51 -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
9569f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp-simd -fopenmp-version=51 -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
9579f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp-simd -fopenmp-version=51 -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
9589f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -verify -fopenmp-simd -fopenmp-version=51 -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
9599f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp-simd -fopenmp-version=51 -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
9609f2f3b9dSJoel E. Denny // RUN: %clang_cc1 -DCK4 -fopenmp-simd -fopenmp-version=51 -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
9619f2f3b9dSJoel E. Denny 
9629f2f3b9dSJoel E. Denny #ifdef CK4
9639f2f3b9dSJoel E. Denny // Mapper function code generation and runtime interface.
9649f2f3b9dSJoel E. Denny 
9659f2f3b9dSJoel E. Denny // CK4-64: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
9669f2f3b9dSJoel E. Denny // CK4-32: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
9679f2f3b9dSJoel E. Denny // PRESENT=0x1000 | TARGET_PARAM=0x20 | TO=0x1 = 0x1021
9689f2f3b9dSJoel E. Denny // CK4: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
9699f2f3b9dSJoel E. Denny 
9709f2f3b9dSJoel E. Denny // CK4-64: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
9719f2f3b9dSJoel E. Denny // CK4-32: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
9729f2f3b9dSJoel E. Denny // PRESENT=0x1000 | TARGET_PARAM=0x20 | FROM=0x2 = 0x1022
9739f2f3b9dSJoel E. Denny // CK4: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1022]]]
9749f2f3b9dSJoel E. Denny 
9759f2f3b9dSJoel E. Denny class C {
9769f2f3b9dSJoel E. Denny public:
9779f2f3b9dSJoel E. Denny   int a;
9789f2f3b9dSJoel E. Denny   double *b;
9799f2f3b9dSJoel E. Denny };
9809f2f3b9dSJoel E. Denny 
9819f2f3b9dSJoel E. Denny #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
9829f2f3b9dSJoel E. Denny 
9839f2f3b9dSJoel E. Denny // CK4: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}})
9849f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
9859f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
9869f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
9879f2f3b9dSJoel E. Denny // CK4: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
9889f2f3b9dSJoel E. Denny // CK4: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
9899f2f3b9dSJoel E. Denny // CK4-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
9909f2f3b9dSJoel E. Denny // CK4-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
9919f2f3b9dSJoel E. Denny // CK4-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
9929f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
9939f2f3b9dSJoel E. Denny // CK4-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
9949f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRBEGIN:%.+]] = bitcast i8** [[VPTRADDR]] to %class.C**
9959f2f3b9dSJoel E. Denny // CK4-DAG: [[PTREND:%.+]] = getelementptr %class.C*, %class.C** [[PTRBEGIN]], i64 [[SIZE]]
9969f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
9979f2f3b9dSJoel E. Denny // CK4-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
9989f2f3b9dSJoel E. Denny // CK4: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
9999f2f3b9dSJoel E. Denny // CK4: br i1 [[ISARRAY]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
10009f2f3b9dSJoel E. Denny 
10019f2f3b9dSJoel E. Denny // CK4: [[INITEVALDEL]]
10029f2f3b9dSJoel E. Denny // CK4: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
10039f2f3b9dSJoel E. Denny // CK4: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
10049f2f3b9dSJoel E. Denny // CK4: br i1 [[ISNOTDEL]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
10059f2f3b9dSJoel E. Denny // CK4: [[INIT]]
10069f2f3b9dSJoel E. Denny // CK4-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
10079f2f3b9dSJoel E. Denny // CK4-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
10089f2f3b9dSJoel E. Denny // CK4-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
10099f2f3b9dSJoel E. Denny // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE]])
10109f2f3b9dSJoel E. Denny // CK4: br label %[[LHEAD:[^,]+]]
10119f2f3b9dSJoel E. Denny 
10129f2f3b9dSJoel E. Denny // CK4: [[LHEAD]]
10139f2f3b9dSJoel E. Denny // CK4: [[ISEMPTY:%.+]] = icmp eq %class.C** [[PTRBEGIN]], [[PTREND]]
10149f2f3b9dSJoel E. Denny // CK4: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
10159f2f3b9dSJoel E. Denny // CK4: [[LBODY]]
10169f2f3b9dSJoel E. Denny // CK4: [[PTR:%.+]] = phi %class.C** [ [[PTRBEGIN]], %[[LHEAD]] ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
10179f2f3b9dSJoel E. Denny // CK4: [[OBJ:%.+]] = load %class.C*, %class.C** [[PTR]]
10189f2f3b9dSJoel E. Denny // CK4-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 0
10199f2f3b9dSJoel E. Denny // CK4-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
10209f2f3b9dSJoel E. Denny // CK4-DAG: [[BBEGIN2:%.+]] = getelementptr inbounds %class.C, %class.C* [[OBJ]], i32 0, i32 1
10219f2f3b9dSJoel E. Denny // CK4-DAG: [[BARRBEGIN:%.+]] = load double*, double** [[BBEGIN2]]
10229f2f3b9dSJoel E. Denny // CK4-DAG: [[BARRBEGINGEP:%.+]] = getelementptr inbounds double, double* [[BARRBEGIN]], i[[sz:64|32]] 0
10239f2f3b9dSJoel E. Denny // CK4-DAG: [[BEND:%.+]] = getelementptr double*, double** [[BBEGIN]], i32 1
10249f2f3b9dSJoel E. Denny // CK4-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10259f2f3b9dSJoel E. Denny // CK4-DAG: [[BENDV:%.+]] = bitcast double** [[BEND]] to i8*
10269f2f3b9dSJoel E. Denny // CK4-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
10279f2f3b9dSJoel E. Denny // CK4-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
10289f2f3b9dSJoel E. Denny // CK4-DAG: [[CSIZE:%.+]] = sub i64 [[BENDI]], [[ABEGINI]]
10299f2f3b9dSJoel E. Denny // CK4-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
10309f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
10319f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10329f2f3b9dSJoel E. Denny // CK4-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
10339f2f3b9dSJoel E. Denny // CK4-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
10349f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[MEMBER:[^,]+]]
10359f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBER]]
10369f2f3b9dSJoel E. Denny // CK4-DAG: br i1 true, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
10379f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOM]]
10389f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 32, [[SHIPRESIZE]]
10399f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[LTYPE]]
10409f2f3b9dSJoel E. Denny // CK4-DAG: [[LTYPE]]
10419f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 32, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
10429f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
10439f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
10449f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
10459f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
10469f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
10479f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
10489f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
10499f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
10509f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
10519f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
10529f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
10539f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10549f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
10559f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
10569f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
10579f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
10589f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
10599f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10609f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
10619f2f3b9dSJoel E. Denny // CK4-DAG: [[PHITYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
10629f2f3b9dSJoel E. Denny // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[PHITYPE0]])
10639f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[OBJ]] to i8*
10649f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10659f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[MEMBER:[^,]+]]
10669f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBER]]
10679f2f3b9dSJoel E. Denny // CK4-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
10689f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOM]]
10699f2f3b9dSJoel E. Denny // 281474976710659 == 0x1,000,000,003
10709f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
10719f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[LTYPE]]
10729f2f3b9dSJoel E. Denny // CK4-DAG: [[LTYPE]]
10739f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710659, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
10749f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
10759f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
10769f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
10779f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
10789f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
10799f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
10809f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
10819f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
10829f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
10839f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
10849f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
10859f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10869f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
10879f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
10889f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
10899f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
10909f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
10919f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10929f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
10939f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
10949f2f3b9dSJoel E. Denny // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]])
10959f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTRADDR2BC:%.+]] = bitcast double** [[BBEGIN]] to i8*
10969f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR2BC:%.+]] = bitcast double* [[BARRBEGINGEP]] to i8*
10979f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[MEMBER:[^,]+]]
10989f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBER]]
10999f2f3b9dSJoel E. Denny // CK4-DAG: br i1 false, label %[[LTYPE:[^,]+]], label %[[MEMBERCOM:[^,]+]]
11009f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOM]]
11019f2f3b9dSJoel E. Denny // 281474976710675 == 0x1,000,000,013
11029f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERCOMTYPE:%.+]] = add nuw i64 281474976710675, [[SHIPRESIZE]]
11039f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[LTYPE]]
11049f2f3b9dSJoel E. Denny // CK4-DAG: [[LTYPE]]
11059f2f3b9dSJoel E. Denny // CK4-DAG: [[MEMBERTYPE:%.+]] = phi i64 [ 281474976710675, %[[MEMBER]] ], [ [[MEMBERCOMTYPE]], %[[MEMBERCOM]] ]
11069f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
11079f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
11089f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
11099f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
11109f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
11119f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
11129f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
11139f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
11149f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
11159f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
11169f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
11179f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11189f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
11199f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
11209f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
11219f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
11229f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
11239f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11249f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
11259f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE2:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
11269f2f3b9dSJoel E. Denny // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR2BC]], i8* [[PTRADDR2BC]], i64 16, i64 [[TYPE2]])
11279f2f3b9dSJoel E. Denny // CK4: [[PTRNEXT]] = getelementptr %class.C*, %class.C** [[PTR]], i32 1
11289f2f3b9dSJoel E. Denny // CK4: [[ISDONE:%.+]] = icmp eq %class.C** [[PTRNEXT]], [[PTREND]]
11299f2f3b9dSJoel E. Denny // CK4: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
11309f2f3b9dSJoel E. Denny 
11319f2f3b9dSJoel E. Denny // CK4: [[LEXIT]]
11329f2f3b9dSJoel E. Denny // CK4: [[ISARRAY:%.+]] = icmp sge i64 [[SIZE]], 1
11339f2f3b9dSJoel E. Denny // CK4: br i1 [[ISARRAY]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
11349f2f3b9dSJoel E. Denny // CK4: [[EVALDEL]]
11359f2f3b9dSJoel E. Denny // CK4: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
11369f2f3b9dSJoel E. Denny // CK4: [[ISDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
11379f2f3b9dSJoel E. Denny // CK4: br i1 [[ISDEL]], label %[[DEL:[^,]+]], label %[[DONE]]
11389f2f3b9dSJoel E. Denny // CK4: [[DEL]]
11399f2f3b9dSJoel E. Denny // CK4-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
11409f2f3b9dSJoel E. Denny // CK4-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
11419f2f3b9dSJoel E. Denny // CK4-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
11429f2f3b9dSJoel E. Denny // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE]])
11439f2f3b9dSJoel E. Denny // CK4: br label %[[DONE]]
11449f2f3b9dSJoel E. Denny // CK4: [[DONE]]
11459f2f3b9dSJoel E. Denny // CK4: ret void
11469f2f3b9dSJoel E. Denny 
11479f2f3b9dSJoel E. Denny 
11489f2f3b9dSJoel E. Denny // CK4-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
11499f2f3b9dSJoel E. Denny void foo(int a){
11509f2f3b9dSJoel E. Denny   int i = a;
11519f2f3b9dSJoel E. Denny   C c;
11529f2f3b9dSJoel E. Denny   c.a = a;
11539f2f3b9dSJoel E. Denny 
1154*da8bec47SJoseph Huber   // CK4-DAG: call void @__tgt_target_data_update_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[TGEPBP:%.+]], i8** [[TGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[TSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[TTYPES]]{{.+}}, i8** null, i8** [[TMPRGEP:%.+]])
11559f2f3b9dSJoel E. Denny   // CK4-DAG: [[TGEPBP]] = getelementptr inbounds {{.+}}[[TBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11569f2f3b9dSJoel E. Denny   // CK4-DAG: [[TGEPP]] = getelementptr inbounds {{.+}}[[TP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11579f2f3b9dSJoel E. Denny   // CK4-DAG: [[TMPRGEP]] = bitcast [1 x i8*]* [[TMPR:%[^,]+]] to i8**
11589f2f3b9dSJoel E. Denny   // CK4-DAG: [[TBP0:%.+]] = getelementptr inbounds {{.+}}[[TBP]], i{{.+}} 0, i{{.+}} 0
11599f2f3b9dSJoel E. Denny   // CK4-DAG: [[TP0:%.+]] = getelementptr inbounds {{.+}}[[TP]], i{{.+}} 0, i{{.+}} 0
11609f2f3b9dSJoel E. Denny   // CK4-DAG: [[TMPR1:%.+]] = getelementptr inbounds {{.+}}[[TMPR]], i[[sz]] 0, i[[sz]] 0
11619f2f3b9dSJoel E. Denny   // CK4-DAG: [[TCBP0:%.+]] = bitcast i8** [[TBP0]] to %class.C**
11629f2f3b9dSJoel E. Denny   // CK4-DAG: [[TCP0:%.+]] = bitcast i8** [[TP0]] to %class.C**
11639f2f3b9dSJoel E. Denny   // CK4-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[TCBP0]]
11649f2f3b9dSJoel E. Denny   // CK4-DAG: store %class.C* [[VAL]], %class.C** [[TCP0]]
11659f2f3b9dSJoel E. Denny   // CK4-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[TMPR1]]
11669f2f3b9dSJoel E. Denny   #pragma omp target update to(present, mapper(id): c)
11679f2f3b9dSJoel E. Denny 
1168*da8bec47SJoseph Huber   // CK4-DAG: call void @__tgt_target_data_update_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** [[FGEPBP:%.+]], i8** [[FGEPP:%.+]], i64* getelementptr {{.+}}[1 x i64]* [[FSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[FTYPES]]{{.+}}, i8** null, i8** [[FMPRGEP:%.+]])
11699f2f3b9dSJoel E. Denny   // CK4-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11709f2f3b9dSJoel E. Denny   // CK4-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11719f2f3b9dSJoel E. Denny   // CK4-DAG: [[FMPRGEP]] = bitcast [1 x i8*]* [[FMPR:%[^,]+]] to i8**
11729f2f3b9dSJoel E. Denny   // CK4-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0
11739f2f3b9dSJoel E. Denny   // CK4-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0
11749f2f3b9dSJoel E. Denny   // CK4-DAG: [[FMPR1:%.+]] = getelementptr inbounds {{.+}}[[FMPR]], i[[sz]] 0, i[[sz]] 0
11759f2f3b9dSJoel E. Denny   // CK4-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C**
11769f2f3b9dSJoel E. Denny   // CK4-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C**
11779f2f3b9dSJoel E. Denny   // CK4-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]]
11789f2f3b9dSJoel E. Denny   // CK4-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]]
11799f2f3b9dSJoel E. Denny   // CK4-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64)* [[MPRFUNC]] to i8*), i8** [[FMPR1]]
11809f2f3b9dSJoel E. Denny   #pragma omp target update from(mapper(id), present: c)
11819f2f3b9dSJoel E. Denny }
11829f2f3b9dSJoel E. Denny 
11839f2f3b9dSJoel E. Denny #endif // CK4
11849f2f3b9dSJoel E. Denny 
1185537b16e9SGeorge Rokos #endif // HEADER
1186