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 ///==========================================================================///
8532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
9532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
10532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
11532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
12532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
13532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
15532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
16532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
17532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
18532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
19532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
20532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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]
61b272698dSAlexey Bataev // CK0: [[EDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 1]
62537b16e9SGeorge Rokos // CK0-64: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
63537b16e9SGeorge Rokos // CK0-32: [[EDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
64b272698dSAlexey Bataev // CK0: [[EDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 1]
65537b16e9SGeorge Rokos // CK0-64: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
66537b16e9SGeorge Rokos // CK0-32: [[EXDSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
67b272698dSAlexey Bataev // CK0: [[EXDTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 2]
68537b16e9SGeorge Rokos // CK0-64: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
69537b16e9SGeorge Rokos // CK0-32: [[EXDNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
70b272698dSAlexey Bataev // CK0: [[EXDNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 2]
71d47b9438SMichael Kruse // CK0-64: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
72d47b9438SMichael Kruse // CK0-32: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
73b272698dSAlexey Bataev // CK0: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 1]
74d47b9438SMichael Kruse // CK0-64: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
75d47b9438SMichael Kruse // CK0-32: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
76b272698dSAlexey Bataev // CK0: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 2]
77537b16e9SGeorge Rokos // CK0-64: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
78537b16e9SGeorge Rokos // CK0-32: [[FNWSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
79b272698dSAlexey Bataev // CK0: [[FNWTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 2]
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
89e4eaf9d8SJoseph Huber // CK0: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
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: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
101d47b9438SMichael Kruse // CK0-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
10260d71a28SAlexey Bataev // CK0-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
10360d71a28SAlexey Bataev // CK0-DAG: [[PTRBEGIN:%.+]] = bitcast i8* [[BEGIN]] to %class.C*
10460d71a28SAlexey Bataev // CK0-DAG: [[PTREND:%.+]] = getelementptr %class.C, %class.C* [[PTRBEGIN]], i64 [[SIZE]]
105caff8591SNikita Popov // CK0-DAG: [[PTRSNE:%.+]] = icmp ne i8* [[BPTR]], [[BEGIN]]
1060caf736dSAlexey Bataev // CK0-DAG: [[PTRANDOBJ:%.+]] = and i64 [[TYPE]], 16
1070caf736dSAlexey Bataev // CK0-DAG: [[ISPTRANDOBJ:%.+]] = icmp ne i64 [[PTRANDOBJ]], 0
1080caf736dSAlexey Bataev // CK0-DAG: [[CMPA:%.+]] = and i1 [[PTRSNE]], [[ISPTRANDOBJ]]
1090caf736dSAlexey Bataev // CK0-DAG: [[CMP:%.+]] = or i1 [[ISARRAY]], [[CMPA]]
11060d71a28SAlexey Bataev // CK0-DAG: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
11160d71a28SAlexey Bataev // CK0-DAG: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
11260d71a28SAlexey Bataev // CK0-DAG: [[CMP1:%.+]] = and i1 [[CMP]], [[ISNOTDEL]]
11360d71a28SAlexey Bataev // CK0: br i1 [[CMP1]], label %[[INIT:[^,]+]], label %[[LHEAD:[^,]+]]
114d47b9438SMichael Kruse // CK0: [[INIT]]
115d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
116d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
11707988422SAlexey Bataev
11807988422SAlexey Bataev // Remove movement mappings and mark as implicit
11907988422SAlexey Bataev // CK0-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
12007988422SAlexey Bataev // CK0-DAG: [[ITYPE1:%.+]] = or i64 [[ITYPE]], 512
12107988422SAlexey Bataev // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE1]], {{.*}})
122d47b9438SMichael Kruse // CK0: br label %[[LHEAD:[^,]+]]
1234304e9d1SMichael Kruse
124d47b9438SMichael Kruse // CK0: [[LHEAD]]
12560d71a28SAlexey Bataev // CK0: [[ISEMPTY:%.+]] = icmp eq %class.C* [[PTRBEGIN]], [[PTREND]]
126d47b9438SMichael Kruse // CK0: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
127d47b9438SMichael Kruse // CK0: [[LBODY]]
12860d71a28SAlexey Bataev // CK0: [[PTR:%.+]] = phi %class.C* [ [[PTRBEGIN]], %{{.+}} ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
12960d71a28SAlexey Bataev // CK0-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 0
13060d71a28SAlexey Bataev // CK0-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 1
13160d71a28SAlexey Bataev // CK0-DAG: [[BBEGIN2:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 1
132d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGIN:%.+]] = load double*, double** [[BBEGIN2]]
133d47b9438SMichael Kruse // CK0-DAG: [[BARRBEGINGEP:%.+]] = getelementptr inbounds double, double* [[BARRBEGIN]], i[[sz:64|32]] 0
134d47b9438SMichael Kruse // CK0-DAG: [[BEND:%.+]] = getelementptr double*, double** [[BBEGIN]], i32 1
135d47b9438SMichael Kruse // CK0-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
136d47b9438SMichael Kruse // CK0-DAG: [[BENDV:%.+]] = bitcast double** [[BEND]] to i8*
137d47b9438SMichael Kruse // CK0-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
138d47b9438SMichael Kruse // CK0-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
139d47b9438SMichael Kruse // CK0-DAG: [[CSIZE:%.+]] = sub i64 [[BENDI]], [[ABEGINI]]
140d47b9438SMichael Kruse // CK0-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
141d47b9438SMichael Kruse // CK0-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
142d47b9438SMichael Kruse // CK0-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
14360d71a28SAlexey Bataev // CK0-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
14460d71a28SAlexey Bataev // CK0-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
14560d71a28SAlexey Bataev // CK0-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 0, [[SHIPRESIZE]]
146d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
147d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
148d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
149d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
150d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
151d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
152d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
153d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
154d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
155d47b9438SMichael Kruse // CK0-DAG: [[TO]]
156d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
157d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
158d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
159d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
160d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
161d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
162d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
163d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
164d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
165d47b9438SMichael Kruse // CK0-DAG: [[PHITYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
166e4eaf9d8SJoseph Huber // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[PHITYPE0]], {{.*}})
16760d71a28SAlexey Bataev // CK0-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
168d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
169d47b9438SMichael Kruse // 281474976710659 == 0x1,000,000,003
17060d71a28SAlexey Bataev // CK0-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
171d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
172d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
173d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
174d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
175d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
176d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
177d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
178d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
179d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
180d47b9438SMichael Kruse // CK0-DAG: [[TO]]
181d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
182d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
183d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
184d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
185d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
186d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
187d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
188d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
189d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
190d47b9438SMichael Kruse // CK0-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
191e4eaf9d8SJoseph Huber // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]], {{.*}})
192d47b9438SMichael Kruse // CK0-DAG: [[BPTRADDR2BC:%.+]] = bitcast double** [[BBEGIN]] to i8*
193d47b9438SMichael Kruse // CK0-DAG: [[PTRADDR2BC:%.+]] = bitcast double* [[BARRBEGINGEP]] to i8*
194d47b9438SMichael Kruse // 281474976710675 == 0x1,000,000,013
19560d71a28SAlexey Bataev // CK0-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 281474976710675, [[SHIPRESIZE]]
196d47b9438SMichael Kruse // CK0-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
197d47b9438SMichael Kruse // CK0-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
198d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
199d47b9438SMichael Kruse // CK0-DAG: [[ALLOC]]
200d47b9438SMichael Kruse // CK0-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
201d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND:[^,]+]]
202d47b9438SMichael Kruse // CK0-DAG: [[ALLOCELSE]]
203d47b9438SMichael Kruse // CK0-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
204d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
205d47b9438SMichael Kruse // CK0-DAG: [[TO]]
206d47b9438SMichael Kruse // CK0-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
207d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
208d47b9438SMichael Kruse // CK0-DAG: [[TOELSE]]
209d47b9438SMichael Kruse // CK0-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
210d47b9438SMichael Kruse // CK0-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
211d47b9438SMichael Kruse // CK0-DAG: [[FROM]]
212d47b9438SMichael Kruse // CK0-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
213d47b9438SMichael Kruse // CK0-DAG: br label %[[TYEND]]
214d47b9438SMichael Kruse // CK0-DAG: [[TYEND]]
215d47b9438SMichael Kruse // CK0-DAG: [[TYPE2:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
216e4eaf9d8SJoseph Huber // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR2BC]], i8* [[PTRADDR2BC]], i64 16, i64 [[TYPE2]], {{.*}})
21760d71a28SAlexey Bataev // CK0: [[PTRNEXT]] = getelementptr %class.C, %class.C* [[PTR]], i32 1
21860d71a28SAlexey Bataev // CK0: [[ISDONE:%.+]] = icmp eq %class.C* [[PTRNEXT]], [[PTREND]]
219d47b9438SMichael Kruse // CK0: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
220d47b9438SMichael Kruse
221d47b9438SMichael Kruse // CK0: [[LEXIT]]
22260d71a28SAlexey Bataev // CK0: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
223d47b9438SMichael Kruse // CK0: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
22460d71a28SAlexey Bataev // CK0: [[ISNOTDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
2250caf736dSAlexey Bataev // CK0: [[CMP1:%.+]] = and i1 [[ISARRAY]], [[ISNOTDEL]]
22660d71a28SAlexey Bataev // CK0: br i1 [[CMP1]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
22760d71a28SAlexey Bataev // CK0: [[EVALDEL]]
228d47b9438SMichael Kruse // CK0-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
229d47b9438SMichael Kruse // CK0-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
23007988422SAlexey Bataev
23107988422SAlexey Bataev // Remove movement mappings and mark as implicit
23207988422SAlexey Bataev // CK0-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
23307988422SAlexey Bataev // CK0-DAG: [[DTYPE1:%.+]] = or i64 [[DTYPE]], 512
23407988422SAlexey Bataev // CK0: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE1]], {{.*}})
235d47b9438SMichael Kruse // CK0: br label %[[DONE]]
236d47b9438SMichael Kruse // CK0: [[DONE]]
237d47b9438SMichael Kruse // CK0: ret void
238d47b9438SMichael Kruse
239d47b9438SMichael Kruse
240d47b9438SMichael Kruse // CK0-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
foo(int a)2414304e9d1SMichael Kruse void foo(int a){
2424304e9d1SMichael Kruse int i = a;
2434304e9d1SMichael Kruse C c;
2444304e9d1SMichael Kruse c.a = a;
2454304e9d1SMichael Kruse
246*1fff1166SJoseph Huber // CK0-DAG: call i32 @__tgt_target_kernel(%struct.ident_t* @{{.+}}, i64 -1, i32 -1, i32 0, i8* @.{{.+}}.region_id, %struct.__tgt_kernel_arguments* [[ARGS:%.+]])
247*1fff1166SJoseph Huber // CK0-DAG: [[BPARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 2
248*1fff1166SJoseph Huber // CK0-DAG: store i8** [[BPGEP:%.+]], i8*** [[BPARG]]
249*1fff1166SJoseph Huber // CK0-DAG: [[PARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 3
250*1fff1166SJoseph Huber // CK0-DAG: store i8** [[PGEP:%.+]], i8*** [[PARG]]
251*1fff1166SJoseph Huber // CK0-DAG: [[MARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 7
252*1fff1166SJoseph Huber // CK0-DAG: store i8** [[MPRGEP:%.+]], i8*** [[MARG]]
253d47b9438SMichael Kruse // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
254d47b9438SMichael Kruse // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
255537b16e9SGeorge Rokos // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
256d47b9438SMichael Kruse // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
257d47b9438SMichael Kruse // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
258537b16e9SGeorge Rokos // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
259d47b9438SMichael Kruse // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
260d47b9438SMichael Kruse // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
261d47b9438SMichael Kruse // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
262d47b9438SMichael Kruse // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
263e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
264ebb1092aSShilei Tian // CK0: call void [[KERNEL_1:@.+]](%class.C* [[VAL]])
265*1fff1166SJoseph Huber #pragma omp target map(mapper(id), tofrom \
266*1fff1166SJoseph Huber : c)
2674304e9d1SMichael Kruse {
2684304e9d1SMichael Kruse ++c.a;
2694304e9d1SMichael Kruse }
27001f670dfSMichael Kruse
271ebb1092aSShilei Tian // CK0: [[BP2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_BP2:%[^,]+]], i32 0, i32 0
272ebb1092aSShilei Tian // CK0: [[BP2CAST:%.+]] = bitcast i8** [[BP2GEP]] to %class.C**
273ebb1092aSShilei Tian // CK0: store %class.C* [[CADDR:%[^,]+]], %class.C** [[BP2CAST]], align
274ebb1092aSShilei Tian // CK0: [[P2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_P2:%[^,]+]], i32 0, i32 0
275ebb1092aSShilei Tian // CK0: [[P2CAST:%.+]] = bitcast i8** [[P2GEP]] to %class.C**
276ebb1092aSShilei Tian // CK0: store %class.C* [[CADDR]], %class.C** [[P2CAST]], align
277ebb1092aSShilei Tian // CK0: [[MAPPER2GEP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_MAPPER2:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
278e4eaf9d8SJoseph Huber // CK0: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MAPPER2GEP]], align
279ebb1092aSShilei Tian // CK0: [[BP2:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_BP2]], i32 0, i32 0
280ebb1092aSShilei Tian // CK0: [[P2:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OFFLOAD_P2]], i32 0, i32 0
281ebb1092aSShilei Tian // CK0: [[MAPPER2:%.+]] = bitcast [1 x i8*]* [[OFFLOAD_MAPPER2]] to i8**
282ebb1092aSShilei 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)
283ebb1092aSShilei 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)
284ebb1092aSShilei Tian // CK0: [[TASK_CAST:%.+]] = bitcast i8* [[TASK]] to [[KMP_TASK_T_WITH_PRIVATES]]*
285ebb1092aSShilei Tian // CK0: [[TASK_WITH_PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_CAST]], i32 0, i32 1
286ebb1092aSShilei Tian // CK0: {{.+}} = call i32 @__kmpc_omp_task([[IDENT_T]]* @1, i32 {{.+}}, i8* [[TASK]])
287537b16e9SGeorge Rokos #pragma omp target map(mapper(id),tofrom: c) nowait
288537b16e9SGeorge Rokos {
289537b16e9SGeorge Rokos ++c.a;
290537b16e9SGeorge Rokos }
291537b16e9SGeorge Rokos
292*1fff1166SJoseph Huber // CK0-DAG: call i32 @__tgt_target_kernel(%struct.ident_t* @{{.+}}, i64 -1, i32 0, i32 0, i8* @.{{.+}}.region_id, %struct.__tgt_kernel_arguments* [[ARGS:%.+]])
293*1fff1166SJoseph Huber // CK0-DAG: [[BPARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 2
294*1fff1166SJoseph Huber // CK0-DAG: store i8** [[BPGEP:%.+]], i8*** [[BPARG]]
295*1fff1166SJoseph Huber // CK0-DAG: [[PARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 3
296*1fff1166SJoseph Huber // CK0-DAG: store i8** [[PGEP:%.+]], i8*** [[PARG]]
297*1fff1166SJoseph Huber // CK0-DAG: [[MARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 7
298*1fff1166SJoseph Huber // CK0-DAG: store i8** [[MPRGEP:%.+]], i8*** [[MARG]]
299537b16e9SGeorge Rokos // CK0-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
300537b16e9SGeorge Rokos // CK0-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
301537b16e9SGeorge Rokos // CK0-DAG: [[MPRGEP]] = bitcast [1 x i8*]* [[MPR:%[^,]+]] to i8**
302537b16e9SGeorge Rokos // CK0-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
303537b16e9SGeorge Rokos // CK0-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
304537b16e9SGeorge Rokos // CK0-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i[[sz]] 0, i[[sz]] 0
305537b16e9SGeorge Rokos // CK0-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C**
306537b16e9SGeorge Rokos // CK0-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
307537b16e9SGeorge Rokos // CK0-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]]
308537b16e9SGeorge Rokos // CK0-DAG: store %class.C* [[VAL]], %class.C** [[CP1]]
309e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
310ebb1092aSShilei Tian // CK0: call void [[KERNEL_3:@.+]](%class.C* [[VAL]])
311*1fff1166SJoseph Huber #pragma omp target teams map(mapper(id), to \
312*1fff1166SJoseph Huber : 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
328da8bec47SJoseph 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]]
339e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[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
374e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPRGEP]], align
375537b16e9SGeorge Rokos #pragma omp target enter data map(mapper(id),to: c) nowait
376537b16e9SGeorge Rokos
377da8bec47SJoseph 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]]
388e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[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
423e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPRGEP]], align
424537b16e9SGeorge Rokos #pragma omp target exit data map(mapper(id),from: c) nowait
425537b16e9SGeorge Rokos
426da8bec47SJoseph 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]]
437e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[TMPR1]]
43801f670dfSMichael Kruse #pragma omp target update to(mapper(id): c)
4390336c75cSMichael Kruse
440da8bec47SJoseph 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]]
451e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[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
486e4eaf9d8SJoseph Huber // CK0-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[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
5091b1c8d83Shyeongyu kim // CK0: define internal void [[OUTLINED:@.+]](i32 {{.*}}{{[^,]+}}, [[ANON_T]]* noalias noundef [[CTXARG:%.+]])
510*1fff1166SJoseph Huber // CK0-DAG: call i32 @__tgt_target_kernel_nowait(%struct.ident_t* @{{.+}}, i64 -1, i32 -1, i32 0, i8* @.{{.+}}.region_id, %struct.__tgt_kernel_arguments* [[ARGS:%.+]], i32 0, i8* null, i32 0, i8* null)
511*1fff1166SJoseph Huber // CK0-DAG: [[BPARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 2
512*1fff1166SJoseph Huber // CK0-DAG: store i8** [[BPGEP:%.+]], i8*** [[BPARG]]
513*1fff1166SJoseph Huber // CK0-DAG: [[PARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 3
514*1fff1166SJoseph Huber // CK0-DAG: store i8** [[PGEP:%.+]], i8*** [[PARG]]
515*1fff1166SJoseph Huber // CK0-DAG: [[SARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4
516*1fff1166SJoseph Huber // CK0-DAG: store i64* [[SIZEGEP:%.+]], i64** [[SARG]]
517*1fff1166SJoseph Huber // CK0-DAG: [[MARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 7
518*1fff1166SJoseph Huber // CK0-DAG: store i8** [[MPRGEP:%.+]], i8*** [[MARG]]
519ebb1092aSShilei Tian // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
520ebb1092aSShilei Tian // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
521ebb1092aSShilei Tian // CK0-DAG: [[SIZEGEP]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SIZEFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
522ebb1092aSShilei Tian // CK0-DAG: [[MPRGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
523ebb1092aSShilei Tian // CK0-DAG: [[BPFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_BP:%.+]], align
524ebb1092aSShilei Tian // CK0-DAG: [[PFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_P:%.+]], align
525ebb1092aSShilei Tian // CK0-DAG: [[SIZEFPADDR]] = load [1 x i64]*, [1 x i64]** [[FPPTRADDR_SIZE:%.+]], align
526ebb1092aSShilei Tian // CK0-DAG: [[MPRFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_MPR:%.+]], align
527a28e835eSAlexey Bataev // CK0-DAG: [[FN:%.+]] = bitcast void (i8*, ...)* %1 to void (i8*, [1 x i8*]**, [1 x i8*]**, [1 x i64]**, [1 x i8*]**)*
528a28e835eSAlexey Bataev // CK0-DAG: call void [[FN]](i8* %2, {{.+}}[[FPPTRADDR_BP]], {{.+}}[[FPPTRADDR_P]], {{.+}}[[FPPTRADDR_SIZE]], {{.+}}[[FPPTRADDR_MPR]])
529ebb1092aSShilei Tian // CK0-DAG: call void [[KERNEL_2:@.+]](%class.C* [[KERNELARG:%.+]])
530ebb1092aSShilei Tian // CK0-DAG: [[KERNELARG]] = load %class.C*, %class.C** [[KERNELARGGEP:%.+]], align
531ebb1092aSShilei Tian // CK0-DAG: [[KERNELARGGEP]] = getelementptr inbounds [[ANON_T]], [[ANON_T]]* [[CTX:%.+]], i32 0, i32 0
532ebb1092aSShilei Tian // CK0-DAG: [[CTX]] = load [[ANON_T]]*, [[ANON_T]]** [[CTXADDR:%.+]], align
533ebb1092aSShilei Tian // CK0-DAG: store [[ANON_T]]* [[CTXARG]], [[ANON_T]]** [[CTXADDR]], align
534ebb1092aSShilei Tian // CK0: }
535ebb1092aSShilei Tian
5361b1c8d83Shyeongyu kim // CK0: define internal {{.*}}i32 [[TASK_ENTRY]](i32 {{.*}}%0, [[KMP_TASK_T_WITH_PRIVATES]]* noalias noundef %1)
537ebb1092aSShilei Tian // CK0: store [[KMP_TASK_T_WITH_PRIVATES]]* %1, [[KMP_TASK_T_WITH_PRIVATES]]** [[ADDR:%.+]], align
538ebb1092aSShilei Tian // CK0: [[TASK_T_WITH_PRIVATES:%.+]] = load [[KMP_TASK_T_WITH_PRIVATES]]*, [[KMP_TASK_T_WITH_PRIVATES]]** [[ADDR]], align
539ebb1092aSShilei Tian // CK0: [[TASKGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 0
540ebb1092aSShilei Tian // CK0: [[SHAREDSGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASKGEP]], i32 0, i32 0
541ebb1092aSShilei Tian // CK0: [[SHAREDS:%.+]] = load i8*, i8** [[SHAREDSGEP]], align
542ebb1092aSShilei Tian // CK0: [[ANON:%.+]] = bitcast i8* [[SHAREDS]] to [[ANON_T]]*
543ebb1092aSShilei Tian // CK0: [[PRIVATESGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]], i32 0, i32 1
544ebb1092aSShilei Tian // CK0: [[PRIVATES:%.+]] = bitcast [[KMP_PRIVATES_T]]* [[PRIVATESGEP]] to i8*
545ebb1092aSShilei Tian // CK0: [[TASK_WITH_PRIVATES:%.+]] = bitcast [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_T_WITH_PRIVATES]] to i8*
546ebb1092aSShilei Tian // CK0: call void [[OUTLINED]](i32 {{%.+}}, i32* {{%.+}}, i8* [[PRIVATES]], {{.+}}, i8* [[TASK_WITH_PRIVATES]], [[ANON_T]]* [[ANON]])
547ebb1092aSShilei Tian // CK0: }
548ebb1092aSShilei Tian
5491b1c8d83Shyeongyu kim // CK0: define internal void [[OUTLINE_1:@.+]](i32 {{.*}}%.global_tid.{{.+}}, [[ANON_T_0]]* noalias noundef [[CTXARG:%.+]])
550*1fff1166SJoseph Huber // CK0-DAG: call i32 @__tgt_target_kernel_nowait(%struct.ident_t* @{{.+}}, i64 -1, i32 0, i32 0, i8* @.{{.+}}.region_id, %struct.__tgt_kernel_arguments* [[ARGS:%.+]], i32 0, i8* null, i32 0, i8* null)
551*1fff1166SJoseph Huber // CK0-DAG: [[BPARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 2
552*1fff1166SJoseph Huber // CK0-DAG: store i8** [[BPGEP:%.+]], i8*** [[BPARG]]
553*1fff1166SJoseph Huber // CK0-DAG: [[PARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 3
554*1fff1166SJoseph Huber // CK0-DAG: store i8** [[PGEP:%.+]], i8*** [[PARG]]
555*1fff1166SJoseph Huber // CK0-DAG: [[SARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 4
556*1fff1166SJoseph Huber // CK0-DAG: store i64* [[SIZEGEP:%.+]], i64** [[SARG]]
557*1fff1166SJoseph Huber // CK0-DAG: [[MARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 7
558*1fff1166SJoseph Huber // CK0-DAG: store i8** [[MPRGEP:%.+]], i8*** [[MARG]]
559ebb1092aSShilei Tian // CK0-DAG: [[BPGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
560ebb1092aSShilei Tian // CK0-DAG: [[PGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
561ebb1092aSShilei Tian // CK0-DAG: [[SIZEGEP]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SIZEFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
562ebb1092aSShilei Tian // CK0-DAG: [[MPRGEP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRFPADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
563ebb1092aSShilei Tian // CK0-DAG: [[BPFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_BP:%.+]], align
564ebb1092aSShilei Tian // CK0-DAG: [[PFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_P:%.+]], align
565ebb1092aSShilei Tian // CK0-DAG: [[SIZEFPADDR]] = load [1 x i64]*, [1 x i64]** [[FPPTRADDR_SIZE:%.+]], align
566ebb1092aSShilei Tian // CK0-DAG: [[MPRFPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPTRADDR_MPR:%.+]], align
567a28e835eSAlexey Bataev // CK0-DAG: [[FN:%.+]] = bitcast void (i8*, ...)* %1 to void (i8*,
568a28e835eSAlexey Bataev // CK0-DAG: call void [[FN]](i8* %2, {{.+}}[[FPPTRADDR_BP]], {{.+}}[[FPPTRADDR_P]], {{.+}}[[FPPTRADDR_SIZE]], {{.+}}[[FPPTRADDR_MPR]])
569ebb1092aSShilei Tian // CK0-DAG: call void [[KERNEL_2:@.+]](%class.C* [[KERNELARG:%.+]])
570ebb1092aSShilei Tian // CK0-DAG: [[KERNELARG]] = load %class.C*, %class.C** [[KERNELARGGEP:%.+]], align
571ebb1092aSShilei Tian // CK0-DAG: [[KERNELARGGEP]] = getelementptr inbounds [[ANON_T_0]], [[ANON_T_0]]* [[CTX:%.+]], i32 0, i32 0
572ebb1092aSShilei Tian // CK0-DAG: [[CTX]] = load [[ANON_T_0]]*, [[ANON_T_0]]** [[CTXADDR:%.+]], align
573ebb1092aSShilei Tian // CK0-DAG: store [[ANON_T_0]]* [[CTXARG]], [[ANON_T_0]]** [[CTXADDR]], align
574ebb1092aSShilei Tian // CK0: }
575ebb1092aSShilei Tian
5761b1c8d83Shyeongyu kim // CK0: define internal {{.*}}i32 [[TASK_ENTRY_1]](i32 {{.*}}%0, [[KMP_TASK_T_WITH_PRIVATES_1]]* noalias noundef %1)
577ebb1092aSShilei Tian // CK0: store [[KMP_TASK_T_WITH_PRIVATES_1]]* %1, [[KMP_TASK_T_WITH_PRIVATES_1]]** [[ADDR:%.+]], align
578ebb1092aSShilei Tian // CK0: [[TASK_T_WITH_PRIVATES:%.+]] = load [[KMP_TASK_T_WITH_PRIVATES_1]]*, [[KMP_TASK_T_WITH_PRIVATES_1]]** [[ADDR]], align
579ebb1092aSShilei 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
580ebb1092aSShilei Tian // CK0: [[SHAREDSGEP:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASKGEP]], i32 0, i32 0
581ebb1092aSShilei Tian // CK0: [[SHAREDS:%.+]] = load i8*, i8** [[SHAREDSGEP]], align
582ebb1092aSShilei Tian // CK0: [[ANON:%.+]] = bitcast i8* [[SHAREDS]] to [[ANON_T_0]]*
583ebb1092aSShilei 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
584ebb1092aSShilei Tian // CK0: [[PRIVATES:%.+]] = bitcast [[KMP_PRIVATES_T_2]]* [[PRIVATESGEP]] to i8*
585ebb1092aSShilei Tian // CK0: [[TASK_WITH_PRIVATES:%.+]] = bitcast [[KMP_TASK_T_WITH_PRIVATES_1]]* [[TASK_T_WITH_PRIVATES]] to i8*
586ebb1092aSShilei Tian // CK0: call void [[OUTLINE_1]](i32 {{%.+}}, i32* {{%.+}}, i8* [[PRIVATES]], {{.+}}, i8* [[TASK_WITH_PRIVATES]], [[ANON_T_0]]* [[ANON]])
587ebb1092aSShilei Tian // CK0: }
588ebb1092aSShilei Tian
5891b1c8d83Shyeongyu kim // CK0: define internal void [[OMP_OUTLINED_16:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias noundef %{{[^,]+}}, i8* noalias noundef %{{[^,]+}}
590da8bec47SJoseph 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:%.+]])
5910661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5920661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5930661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5940661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
5950661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
5960661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
5970661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
5980661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
599a28e835eSAlexey Bataev // CK0-DAG: [[FN:%.+]] = bitcast void (i8*, ...)* %{{.+}} to void (i8*,
600a28e835eSAlexey Bataev // CK0-DAG: call void [[FN]](i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
6010661328dSShilei Tian // CK0: ret void
6020661328dSShilei Tian // CK0: }
6030661328dSShilei Tian
6041b1c8d83Shyeongyu kim // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_18]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_4]]* noalias noundef %{{[^,]+}})
6050661328dSShilei Tian // CK0: call void [[OMP_OUTLINED_16]]
6060661328dSShilei Tian // CK0: ret i32 0
6070661328dSShilei Tian // CK0: }
6080661328dSShilei Tian
6091b1c8d83Shyeongyu kim // CK0: define internal void [[OMP_OUTLINED_23:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias noundef %{{[^,]+}}, i8* noalias noundef %{{[^,]+}}
610da8bec47SJoseph 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:%.+]])
6110661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6120661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6130661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6140661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6150661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
6160661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
6170661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
6180661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
619a28e835eSAlexey Bataev // CK0-DAG: [[FN:%.+]] = bitcast void (i8*, ...)* %{{.+}} to void (i8*,
620a28e835eSAlexey Bataev // CK0-DAG: call void [[FN]](i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
6210661328dSShilei Tian // CK0: }
6220661328dSShilei Tian
6231b1c8d83Shyeongyu kim // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_25]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_7]]* noalias noundef %{{[^,]+}})
6240661328dSShilei Tian // CK0: call void [[OMP_OUTLINED_23]]
6250661328dSShilei Tian // CK0: ret i32 0
6260661328dSShilei Tian // CK0: }
6270661328dSShilei Tian
6281b1c8d83Shyeongyu kim // CK0: define internal void [[OMP_OUTLINED_32:@.+]](i32{{.*}} %{{[^,]+}}, i32* noalias noundef %{{[^,]+}}, i8* noalias noundef %{{[^,]+}}
629da8bec47SJoseph 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:%.+]])
6300661328dSShilei Tian // CK0-DAG: [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6310661328dSShilei Tian // CK0-DAG: [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6320661328dSShilei Tian // CK0-DAG: [[SZ]] = getelementptr inbounds [1 x i64], [1 x i64]* [[SZADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6330661328dSShilei Tian // CK0-DAG: [[MPR]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[MPRADDR:%[^,]+]], i[[sz]] 0, i[[sz]] 0
6340661328dSShilei Tian // CK0-DAG: [[BPADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPBPADDR:%[^,]+]], align
6350661328dSShilei Tian // CK0-DAG: [[PADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPPADDR:%[^,]+]], align
6360661328dSShilei Tian // CK0-DAG: [[SZADDR]] = load [1 x i64]*, [1 x i64]** [[FPSZADDR:%[^,]+]], align
6370661328dSShilei Tian // CK0-DAG: [[MPRADDR]] = load [1 x i8*]*, [1 x i8*]** [[FPMPRADDR:%[^,]+]], align
638a28e835eSAlexey Bataev // CK0-DAG: [[FN:%.+]] = bitcast void (i8*, ...)* %{{.+}} to void (i8*,
639a28e835eSAlexey Bataev // CK0-DAG: call void [[FN]](i8* %{{[^,]+}}, [1 x i8*]** [[FPBPADDR]], [1 x i8*]** [[FPPADDR]], [1 x i64]** [[FPSZADDR]], [1 x i8*]** [[FPMPRADDR]])
6400661328dSShilei Tian // CK0: }
6410661328dSShilei Tian
6421b1c8d83Shyeongyu kim // CK0: define internal {{.*}}i32 [[OMP_TASK_ENTRY_34]](i32 {{.*}}%{{[^,]+}}, [[KMP_TASK_T_WITH_PRIVATES_10]]* noalias noundef %{{[^,]+}})
6430661328dSShilei Tian // CK0: call void [[OMP_OUTLINED_32]]
6440661328dSShilei Tian // CK0: ret i32 0
6450661328dSShilei Tian // CK0: }
6460661328dSShilei Tian
647537b16e9SGeorge Rokos #endif // CK0
648d47b9438SMichael Kruse
649d47b9438SMichael Kruse
650d47b9438SMichael Kruse ///==========================================================================///
651532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
652532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
653532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
654532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
655532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
656532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
657d47b9438SMichael Kruse
658532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
659532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
660532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
661532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
662532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
663532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
664d47b9438SMichael Kruse
665d47b9438SMichael Kruse #ifdef CK1
666537b16e9SGeorge Rokos // C++ template
667d47b9438SMichael Kruse
668d47b9438SMichael Kruse template <class T>
669d47b9438SMichael Kruse class C {
670d47b9438SMichael Kruse public:
671d47b9438SMichael Kruse T a;
672d47b9438SMichael Kruse };
673d47b9438SMichael Kruse
674d47b9438SMichael Kruse #pragma omp declare mapper(id: C<int> s) map(s.a)
675d47b9438SMichael Kruse
676e4eaf9d8SJoseph Huber // CK1-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id{{.*}}(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
677d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
678d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
679d47b9438SMichael Kruse // CK1: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
680d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
681d47b9438SMichael Kruse // CK1: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
682537b16e9SGeorge Rokos // CK1-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
683537b16e9SGeorge Rokos // CK1-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 4
684d47b9438SMichael Kruse // CK1-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
685d47b9438SMichael Kruse // CK1-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
686d47b9438SMichael Kruse // CK1-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
687d47b9438SMichael Kruse // CK1-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
68860d71a28SAlexey Bataev // CK1-DAG: [[PTRBEGIN:%.+]] = bitcast i8* [[BEGIN]] to %class.C*
68960d71a28SAlexey Bataev // CK1-DAG: [[PTREND:%.+]] = getelementptr %class.C, %class.C* [[PTRBEGIN]], i64 [[SIZE]]
69060d71a28SAlexey Bataev // CK1-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
691caff8591SNikita Popov // CK1-DAG: [[PTRSNE:%.+]] = icmp ne i8* [[BPTR]], [[BEGIN]]
6920caf736dSAlexey Bataev // CK1-DAG: [[PTRANDOBJ:%.+]] = and i64 [[TYPE]], 16
6930caf736dSAlexey Bataev // CK1-DAG: [[ISPTRANDOBJ:%.+]] = icmp ne i64 [[PTRANDOBJ]], 0
6940caf736dSAlexey Bataev // CK1-DAG: [[CMPA:%.+]] = and i1 [[PTRSNE]], [[ISPTRANDOBJ]]
6950caf736dSAlexey Bataev // CK1-DAG: [[CMP:%.+]] = or i1 [[ISARRAY]], [[CMPA]]
69660d71a28SAlexey Bataev // CK1-DAG: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
69760d71a28SAlexey Bataev // CK1-DAG: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
69860d71a28SAlexey Bataev // CK1-DAG: [[CMP1:%.+]] = and i1 [[CMP]], [[ISNOTDEL]]
69960d71a28SAlexey Bataev // CK1: br i1 [[CMP1]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
700d47b9438SMichael Kruse
701d47b9438SMichael Kruse // CK1: [[INITEVALDEL]]
702d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
70307988422SAlexey Bataev
70407988422SAlexey Bataev // Remove movement mappings and mark as implicit
70507988422SAlexey Bataev // CK1-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
70607988422SAlexey Bataev // CK1-DAG: [[ITYPE1:%.+]] = or i64 [[ITYPE]], 512
70707988422SAlexey Bataev // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE1]], {{.*}})
708d47b9438SMichael Kruse // CK1: br label %[[LHEAD:[^,]+]]
709d47b9438SMichael Kruse
710d47b9438SMichael Kruse // CK1: [[LHEAD]]
71160d71a28SAlexey Bataev // CK1: [[ISEMPTY:%.+]] = icmp eq %class.C* [[PTRBEGIN]], [[PTREND]]
712d47b9438SMichael Kruse // CK1: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
713d47b9438SMichael Kruse // CK1: [[LBODY]]
71460d71a28SAlexey Bataev // CK1: [[PTR:%.+]] = phi %class.C* [ [[PTRBEGIN]], %{{.+}} ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
71560d71a28SAlexey Bataev // CK1-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 0
716d47b9438SMichael Kruse // CK1-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
717d47b9438SMichael Kruse // CK1-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
71860d71a28SAlexey Bataev // CK1-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
719d47b9438SMichael Kruse // CK1-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
72060d71a28SAlexey Bataev // CK1-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 3, [[SHIPRESIZE]]
721d47b9438SMichael Kruse // CK1-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
722d47b9438SMichael Kruse // CK1-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
723d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
724d47b9438SMichael Kruse // CK1-DAG: [[ALLOC]]
725d47b9438SMichael Kruse // CK1-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
726d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND:[^,]+]]
727d47b9438SMichael Kruse // CK1-DAG: [[ALLOCELSE]]
728d47b9438SMichael Kruse // CK1-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
729d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
730d47b9438SMichael Kruse // CK1-DAG: [[TO]]
731d47b9438SMichael Kruse // CK1-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
732d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
733d47b9438SMichael Kruse // CK1-DAG: [[TOELSE]]
734d47b9438SMichael Kruse // CK1-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
735d47b9438SMichael Kruse // CK1-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
736d47b9438SMichael Kruse // CK1-DAG: [[FROM]]
737d47b9438SMichael Kruse // CK1-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
738d47b9438SMichael Kruse // CK1-DAG: br label %[[TYEND]]
739d47b9438SMichael Kruse // CK1-DAG: [[TYEND]]
740d47b9438SMichael Kruse // CK1-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
741e4eaf9d8SJoseph Huber // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]], {{.*}})
74260d71a28SAlexey Bataev // CK1: [[PTRNEXT]] = getelementptr %class.C, %class.C* [[PTR]], i32 1
74360d71a28SAlexey Bataev // CK1: [[ISDONE:%.+]] = icmp eq %class.C* [[PTRNEXT]], [[PTREND]]
744d47b9438SMichael Kruse // CK1: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
745d47b9438SMichael Kruse
746d47b9438SMichael Kruse // CK1: [[LEXIT]]
74760d71a28SAlexey Bataev // CK1: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
748d47b9438SMichael Kruse // CK1: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
74960d71a28SAlexey Bataev // CK1: [[ISNOTDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
7500caf736dSAlexey Bataev // CK1: [[CMP1:%.+]] = and i1 [[ISARRAY]], [[ISNOTDEL]]
751d47b9438SMichael Kruse // CK1-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 4
75207988422SAlexey Bataev
75307988422SAlexey Bataev // Remove movement mappings and mark as implicit
75407988422SAlexey Bataev // CK1-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
75507988422SAlexey Bataev // CK1-DAG: [[DTYPE1:%.+]] = or i64 [[DTYPE]], 512
75607988422SAlexey Bataev // CK1: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE1]], {{.*}})
757d47b9438SMichael Kruse // CK1: br label %[[DONE]]
758d47b9438SMichael Kruse // CK1: [[DONE]]
759d47b9438SMichael Kruse // CK1: ret void
760d47b9438SMichael Kruse
761537b16e9SGeorge Rokos #endif // CK1
7624304e9d1SMichael Kruse
763537b16e9SGeorge Rokos
764537b16e9SGeorge Rokos ///==========================================================================///
765532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
766532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
767532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
768532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
769532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
770532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
771537b16e9SGeorge Rokos
772532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
773532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
774532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
775532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
776532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
777532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
778537b16e9SGeorge Rokos
779537b16e9SGeorge Rokos #ifdef CK2
780537b16e9SGeorge Rokos // Nested mappers.
781537b16e9SGeorge Rokos
782537b16e9SGeorge Rokos class B {
783537b16e9SGeorge Rokos public:
784537b16e9SGeorge Rokos double a;
785537b16e9SGeorge Rokos };
786537b16e9SGeorge Rokos
787537b16e9SGeorge Rokos class C {
788537b16e9SGeorge Rokos public:
789537b16e9SGeorge Rokos double a;
790537b16e9SGeorge Rokos B b;
791537b16e9SGeorge Rokos };
792537b16e9SGeorge Rokos
793537b16e9SGeorge Rokos #pragma omp declare mapper(B s) map(s.a)
794537b16e9SGeorge Rokos
795537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.b)
796537b16e9SGeorge Rokos
797e4eaf9d8SJoseph Huber // CK2: define {{.*}}void [[BMPRFUNC:@[.]omp_mapper[.].*B[.]default]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
798537b16e9SGeorge Rokos
799e4eaf9d8SJoseph Huber // CK2-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id(i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
800537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
801537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
802537b16e9SGeorge Rokos // CK2: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
803537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
804537b16e9SGeorge Rokos // CK2: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
805537b16e9SGeorge Rokos // CK2-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
806537b16e9SGeorge Rokos // CK2-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
807537b16e9SGeorge Rokos // CK2-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
808537b16e9SGeorge Rokos // CK2-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
809537b16e9SGeorge Rokos // CK2-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
810537b16e9SGeorge Rokos // CK2-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
81160d71a28SAlexey Bataev // CK2-DAG: [[PTRBEGIN:%.+]] = bitcast i8* [[BEGIN]] to %class.C*
81260d71a28SAlexey Bataev // CK2-DAG: [[PTREND:%.+]] = getelementptr %class.C, %class.C* [[PTRBEGIN]], i64 [[SIZE]]
81360d71a28SAlexey Bataev // CK2-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
814caff8591SNikita Popov // CK2-DAG: [[PTRSNE:%.+]] = icmp ne i8* [[BPTR]], [[BEGIN]]
8150caf736dSAlexey Bataev // CK2-DAG: [[PTRANDOBJ:%.+]] = and i64 [[TYPE]], 16
8160caf736dSAlexey Bataev // CK2-DAG: [[ISPTRANDOBJ:%.+]] = icmp ne i64 [[PTRANDOBJ]], 0
8170caf736dSAlexey Bataev // CK2-DAG: [[CMPA:%.+]] = and i1 [[PTRSNE]], [[ISPTRANDOBJ]]
8180caf736dSAlexey Bataev // CK2-DAG: [[CMP:%.+]] = or i1 [[ISARRAY]], [[CMPA]]
81960d71a28SAlexey Bataev // CK2-DAG: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
82060d71a28SAlexey Bataev // CK2-DAG: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
82160d71a28SAlexey Bataev // CK2-DAG: [[CMP1:%.+]] = and i1 [[CMP]], [[ISNOTDEL]]
82260d71a28SAlexey Bataev // CK2: br i1 [[CMP1]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
823537b16e9SGeorge Rokos
824537b16e9SGeorge Rokos // CK2: [[INITEVALDEL]]
825537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
82607988422SAlexey Bataev
82707988422SAlexey Bataev // Remove movement mappings and mark as implicit
82807988422SAlexey Bataev // CK2-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
82907988422SAlexey Bataev // CK2-DAG: [[ITYPE1:%.+]] = or i64 [[ITYPE]], 512
83007988422SAlexey Bataev // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE1]], {{.*}})
831537b16e9SGeorge Rokos // CK2: br label %[[LHEAD:[^,]+]]
832537b16e9SGeorge Rokos
833537b16e9SGeorge Rokos // CK2: [[LHEAD]]
83460d71a28SAlexey Bataev // CK2: [[ISEMPTY:%.+]] = icmp eq %class.C* [[PTRBEGIN]], [[PTREND]]
835537b16e9SGeorge Rokos // CK2: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
836537b16e9SGeorge Rokos // CK2: [[LBODY]]
83760d71a28SAlexey Bataev // CK2: [[PTR:%.+]] = phi %class.C* [ [[PTRBEGIN]], %{{.+}} ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
83860d71a28SAlexey Bataev // CK2-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 1
839537b16e9SGeorge Rokos // CK2-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
840537b16e9SGeorge Rokos // CK2-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
84160d71a28SAlexey Bataev // CK2-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
842537b16e9SGeorge Rokos // CK2-DAG: [[PTRADDR1BC:%.+]] = bitcast %class.B* [[BBEGIN]] to i8*
84360d71a28SAlexey Bataev // CK2-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 3, [[SHIPRESIZE]]
844537b16e9SGeorge Rokos // CK2-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
845537b16e9SGeorge Rokos // CK2-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
846537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
847537b16e9SGeorge Rokos // CK2-DAG: [[ALLOC]]
848537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
849537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND:[^,]+]]
850537b16e9SGeorge Rokos // CK2-DAG: [[ALLOCELSE]]
851537b16e9SGeorge Rokos // CK2-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
852537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
853537b16e9SGeorge Rokos // CK2-DAG: [[TO]]
854537b16e9SGeorge Rokos // CK2-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
855537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
856537b16e9SGeorge Rokos // CK2-DAG: [[TOELSE]]
857537b16e9SGeorge Rokos // CK2-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
858537b16e9SGeorge Rokos // CK2-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
859537b16e9SGeorge Rokos // CK2-DAG: [[FROM]]
860537b16e9SGeorge Rokos // CK2-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
861537b16e9SGeorge Rokos // CK2-DAG: br label %[[TYEND]]
862537b16e9SGeorge Rokos // CK2-DAG: [[TYEND]]
863537b16e9SGeorge Rokos // CK2-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
864e4eaf9d8SJoseph Huber // CK2: call void [[BMPRFUNC]](i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 8, i64 [[TYPE1]], {{.*}})
86560d71a28SAlexey Bataev // CK2: [[PTRNEXT]] = getelementptr %class.C, %class.C* [[PTR]], i32 1
86660d71a28SAlexey Bataev // CK2: [[ISDONE:%.+]] = icmp eq %class.C* [[PTRNEXT]], [[PTREND]]
867537b16e9SGeorge Rokos // CK2: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
868537b16e9SGeorge Rokos
869537b16e9SGeorge Rokos // CK2: [[LEXIT]]
87060d71a28SAlexey Bataev // CK2: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
871537b16e9SGeorge Rokos // CK2: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
87260d71a28SAlexey Bataev // CK2: [[ISNOTDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
8730caf736dSAlexey Bataev // CK2: [[CMP1:%.+]] = and i1 [[ISARRAY]], [[ISNOTDEL]]
87460d71a28SAlexey Bataev // CK2: br i1 [[CMP1]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
87560d71a28SAlexey Bataev // CK2: [[EVALDEL]]
876537b16e9SGeorge Rokos // CK2-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
87707988422SAlexey Bataev
87807988422SAlexey Bataev // Remove movement mappings and mark as implicit
87907988422SAlexey Bataev // CK2-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
88007988422SAlexey Bataev // CK2-DAG: [[DTYPE1:%.+]] = or i64 [[DTYPE]], 512
88107988422SAlexey Bataev // CK2: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE1]], {{.*}})
882537b16e9SGeorge Rokos // CK2: br label %[[DONE]]
883537b16e9SGeorge Rokos // CK2: [[DONE]]
884537b16e9SGeorge Rokos // CK2: ret void
885537b16e9SGeorge Rokos
886537b16e9SGeorge Rokos #endif // CK2
887537b16e9SGeorge Rokos
888537b16e9SGeorge Rokos
889537b16e9SGeorge Rokos ///==========================================================================///
890532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
891532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
892532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
893532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
894532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
895532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
896537b16e9SGeorge Rokos
897532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
898532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
899532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
900532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
901532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
902532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
903537b16e9SGeorge Rokos
904537b16e9SGeorge Rokos #ifdef CK3
905537b16e9SGeorge Rokos // map of array sections and nested components.
906537b16e9SGeorge Rokos
907537b16e9SGeorge Rokos // CK3-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}.region_id = weak constant i8 0
9085292187aSAlexey Bataev // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [2 x i64] [i64 {{8|16}}, i64 {{80|160}}]
9095292187aSAlexey Bataev // CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [2 x i64] [i64 35, i64 35]
910537b16e9SGeorge Rokos
911537b16e9SGeorge Rokos class C {
912537b16e9SGeorge Rokos public:
913537b16e9SGeorge Rokos int a;
914537b16e9SGeorge Rokos double *b;
915537b16e9SGeorge Rokos };
916537b16e9SGeorge Rokos
917537b16e9SGeorge Rokos class B {
918537b16e9SGeorge Rokos public:
919537b16e9SGeorge Rokos C c;
920537b16e9SGeorge Rokos };
921537b16e9SGeorge Rokos
922537b16e9SGeorge Rokos #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
923537b16e9SGeorge Rokos
924e4eaf9d8SJoseph Huber // CK3: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
925537b16e9SGeorge Rokos
926537b16e9SGeorge Rokos // CK3-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
foo(int a)927537b16e9SGeorge Rokos void foo(int a){
928537b16e9SGeorge Rokos // CK3-DAG: [[CVAL:%.+]] = alloca [10 x %class.C]
929537b16e9SGeorge Rokos // CK3-DAG: [[BVAL:%.+]] = alloca %class.B
930537b16e9SGeorge Rokos C c[10];
931537b16e9SGeorge Rokos B b;
932537b16e9SGeorge Rokos
933537b16e9SGeorge Rokos // CK3-DAG: [[BC:%.+]] = getelementptr inbounds %class.B, %class.B* [[BVAL]], i32 0, i32 0
934537b16e9SGeorge Rokos
935*1fff1166SJoseph Huber // CK3-DAG: call i32 @__tgt_target_kernel(%struct.ident_t* @{{.+}}, i64 -1, i32 -1, i32 0, i8* @.{{.+}}.region_id, %struct.__tgt_kernel_arguments* [[ARGS:%.+]])
936*1fff1166SJoseph Huber // CK3-DAG: [[BPARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 2
937*1fff1166SJoseph Huber // CK3-DAG: store i8** [[BPGEP:%.+]], i8*** [[BPARG]]
938*1fff1166SJoseph Huber // CK3-DAG: [[PARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 3
939*1fff1166SJoseph Huber // CK3-DAG: store i8** [[PGEP:%.+]], i8*** [[PARG]]
940*1fff1166SJoseph Huber // CK3-DAG: [[MARG:%.+]] = getelementptr inbounds {{.+}}[[ARGS]], i32 0, i32 7
941*1fff1166SJoseph Huber // CK3-DAG: store i8** [[MPRGEP:%.+]], i8*** [[MARG]]
942537b16e9SGeorge Rokos // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
943537b16e9SGeorge Rokos // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
9445292187aSAlexey Bataev // CK3-DAG: [[MPRGEP]] = bitcast [2 x i8*]* [[MPR:%[^,]+]] to i8**
945537b16e9SGeorge Rokos // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
946537b16e9SGeorge Rokos // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
947537b16e9SGeorge Rokos // CK3-DAG: [[MPR1:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 0
948537b16e9SGeorge Rokos // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.B**
949537b16e9SGeorge Rokos // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C**
950537b16e9SGeorge Rokos // CK3-DAG: store %class.B* [[BVAL]], %class.B** [[CBP1]]
951537b16e9SGeorge Rokos // CK3-DAG: store %class.C* [[BC]], %class.C** [[CP1]]
952e4eaf9d8SJoseph Huber // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPR1]]
953537b16e9SGeorge Rokos // CK3-DAG: [[BP2:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 1
954537b16e9SGeorge Rokos // CK3-DAG: [[P2:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 1
955537b16e9SGeorge Rokos // CK3-DAG: [[MPR2:%.+]] = getelementptr inbounds {{.+}}[[MPR]], i{{64|32}} 0, i{{64|32}} 1
9565292187aSAlexey Bataev // CK3-DAG: [[CBP2:%.+]] = bitcast i8** [[BP2]] to [10 x %class.C]**
957537b16e9SGeorge Rokos // CK3-DAG: [[CP2:%.+]] = bitcast i8** [[P2]] to %class.C**
9585292187aSAlexey Bataev // CK3-DAG: store [10 x %class.C]* [[CVAL]], [10 x %class.C]** [[CBP2]]
959537b16e9SGeorge Rokos // CK3-DAG: [[CVALGEP:%.+]] = getelementptr inbounds {{.+}}[[CVAL]], i{{64|32}} 0, i{{64|32}} 0
9605292187aSAlexey Bataev // CK3-DAG: store %class.C* [[CVALGEP]], %class.C** [[CP2]]
961e4eaf9d8SJoseph Huber // CK3-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[MPR2]]
962537b16e9SGeorge Rokos // CK3: call void [[KERNEL:@.+]](%class.B* [[BVAL]], [10 x %class.C]* [[CVAL]])
963*1fff1166SJoseph Huber #pragma omp target map(mapper(id), tofrom \
964*1fff1166SJoseph Huber : c [0:10], b.c)
965537b16e9SGeorge Rokos for (int i = 0; i < 10; i++) {
966537b16e9SGeorge Rokos b.c.a += ++c[i].a;
967537b16e9SGeorge Rokos }
968537b16e9SGeorge Rokos }
969537b16e9SGeorge Rokos
970537b16e9SGeorge Rokos
971537b16e9SGeorge Rokos // CK3: define internal void [[KERNEL]](%class.B* {{[^,]+}}, [10 x %class.C]* {{[^,]+}})
972537b16e9SGeorge Rokos
973537b16e9SGeorge Rokos #endif // CK3
974537b16e9SGeorge Rokos
9759f2f3b9dSJoel E. Denny ///==========================================================================///
976532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
977532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
978532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
979532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
980532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
981532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
9829f2f3b9dSJoel E. Denny
983532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
984532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
985532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
986532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
987532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
988532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -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
9899f2f3b9dSJoel E. Denny
9909f2f3b9dSJoel E. Denny #ifdef CK4
9919f2f3b9dSJoel E. Denny // Mapper function code generation and runtime interface.
9929f2f3b9dSJoel E. Denny
9939f2f3b9dSJoel E. Denny // CK4-64: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
9949f2f3b9dSJoel E. Denny // CK4-32: [[TSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
995b272698dSAlexey Bataev // PRESENT=0x1000 | TO=0x1 = 0x1001
996b272698dSAlexey Bataev // CK4: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1001]]]
9979f2f3b9dSJoel E. Denny
9989f2f3b9dSJoel E. Denny // CK4-64: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
9999f2f3b9dSJoel E. Denny // CK4-32: [[FSIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
1000b272698dSAlexey Bataev // PRESENT=0x1000 | FROM=0x2 = 0x1002
1001b272698dSAlexey Bataev // CK4: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1002]]]
10029f2f3b9dSJoel E. Denny
10039f2f3b9dSJoel E. Denny class C {
10049f2f3b9dSJoel E. Denny public:
10059f2f3b9dSJoel E. Denny int a;
10069f2f3b9dSJoel E. Denny double *b;
10079f2f3b9dSJoel E. Denny };
10089f2f3b9dSJoel E. Denny
10099f2f3b9dSJoel E. Denny #pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])
10109f2f3b9dSJoel E. Denny
1011e4eaf9d8SJoseph Huber // CK4: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](i8*{{.*}}, i8*{{.*}}, i8*{{.*}}, i64{{.*}}, i64{{.*}}, i8*{{.*}})
10129f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[HANDLEADDR:%[^,]+]]
10139f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[BPTRADDR:%[^,]+]]
10149f2f3b9dSJoel E. Denny // CK4: store i8* %{{[^,]+}}, i8** [[VPTRADDR:%[^,]+]]
10159f2f3b9dSJoel E. Denny // CK4: store i64 %{{[^,]+}}, i{{64|32}}* [[SIZEADDR:%[^,]+]]
10169f2f3b9dSJoel E. Denny // CK4: store i64 %{{[^,]+}}, i64* [[TYPEADDR:%[^,]+]]
10179f2f3b9dSJoel E. Denny // CK4-DAG: [[BYTESIZE:%.+]] = load i64, i64* [[SIZEADDR]]
10189f2f3b9dSJoel E. Denny // CK4-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
10199f2f3b9dSJoel E. Denny // CK4-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
10209f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE:%.+]] = load i64, i64* [[TYPEADDR]]
10219f2f3b9dSJoel E. Denny // CK4-DAG: [[HANDLE:%.+]] = load i8*, i8** [[HANDLEADDR]]
10229f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTR:%.+]] = load i8*, i8** [[BPTRADDR]]
10239f2f3b9dSJoel E. Denny // CK4-DAG: [[BEGIN:%.+]] = load i8*, i8** [[VPTRADDR]]
102460d71a28SAlexey Bataev // CK4-DAG: [[PTRBEGIN:%.+]] = bitcast i8* [[BEGIN]] to %class.C*
102560d71a28SAlexey Bataev // CK4-DAG: [[PTREND:%.+]] = getelementptr %class.C, %class.C* [[PTRBEGIN]], i64 [[SIZE]]
102660d71a28SAlexey Bataev // CK4-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
1027caff8591SNikita Popov // CK4-DAG: [[PTRSNE:%.+]] = icmp ne i8* [[BPTR]], [[BEGIN]]
10280caf736dSAlexey Bataev // CK4-DAG: [[PTRANDOBJ:%.+]] = and i64 [[TYPE]], 16
10290caf736dSAlexey Bataev // CK4-DAG: [[ISPTRANDOBJ:%.+]] = icmp ne i64 [[PTRANDOBJ]], 0
10300caf736dSAlexey Bataev // CK4-DAG: [[CMPA:%.+]] = and i1 [[PTRSNE]], [[ISPTRANDOBJ]]
10310caf736dSAlexey Bataev // CK4-DAG: [[CMP:%.+]] = or i1 [[ISARRAY]], [[CMPA]]
103260d71a28SAlexey Bataev // CK4-DAG: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
103360d71a28SAlexey Bataev // CK4-DAG: [[ISNOTDEL:%.+]] = icmp eq i64 [[TYPEDEL]], 0
103460d71a28SAlexey Bataev // CK4-DAG: [[CMP1:%.+]] = and i1 [[CMP]], [[ISNOTDEL]]
103560d71a28SAlexey Bataev // CK4: br i1 [[CMP1]], label %[[INITEVALDEL:[^,]+]], label %[[LHEAD:[^,]+]]
10369f2f3b9dSJoel E. Denny
10379f2f3b9dSJoel E. Denny // CK4: [[INITEVALDEL]]
10389f2f3b9dSJoel E. Denny // CK4-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
10399f2f3b9dSJoel E. Denny // CK4-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
104007988422SAlexey Bataev
104107988422SAlexey Bataev // Remove movement mappings and mark as implicit
104207988422SAlexey Bataev // CK4-DAG: [[ITYPE:%.+]] = and i64 [[TYPE]], -4
104307988422SAlexey Bataev // CK4-DAG: [[ITYPE1:%.+]] = or i64 [[ITYPE]], 512
104407988422SAlexey Bataev // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[ITYPE1]], {{.*}})
10459f2f3b9dSJoel E. Denny // CK4: br label %[[LHEAD:[^,]+]]
10469f2f3b9dSJoel E. Denny
10479f2f3b9dSJoel E. Denny // CK4: [[LHEAD]]
104860d71a28SAlexey Bataev // CK4: [[ISEMPTY:%.+]] = icmp eq %class.C* [[PTRBEGIN]], [[PTREND]]
10499f2f3b9dSJoel E. Denny // CK4: br i1 [[ISEMPTY]], label %[[DONE:[^,]+]], label %[[LBODY:[^,]+]]
10509f2f3b9dSJoel E. Denny // CK4: [[LBODY]]
105160d71a28SAlexey Bataev // CK4: [[PTR:%.+]] = phi %class.C* [ [[PTRBEGIN]], %{{.+}} ], [ [[PTRNEXT:%.+]], %[[LCORRECT:[^,]+]] ]
105260d71a28SAlexey Bataev // CK4-DAG: [[ABEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 0
105360d71a28SAlexey Bataev // CK4-DAG: [[BBEGIN:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 1
105460d71a28SAlexey Bataev // CK4-DAG: [[BBEGIN2:%.+]] = getelementptr inbounds %class.C, %class.C* [[PTR]], i32 0, i32 1
10559f2f3b9dSJoel E. Denny // CK4-DAG: [[BARRBEGIN:%.+]] = load double*, double** [[BBEGIN2]]
10569f2f3b9dSJoel E. Denny // CK4-DAG: [[BARRBEGINGEP:%.+]] = getelementptr inbounds double, double* [[BARRBEGIN]], i[[sz:64|32]] 0
10579f2f3b9dSJoel E. Denny // CK4-DAG: [[BEND:%.+]] = getelementptr double*, double** [[BBEGIN]], i32 1
10589f2f3b9dSJoel E. Denny // CK4-DAG: [[ABEGINV:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10599f2f3b9dSJoel E. Denny // CK4-DAG: [[BENDV:%.+]] = bitcast double** [[BEND]] to i8*
10609f2f3b9dSJoel E. Denny // CK4-DAG: [[ABEGINI:%.+]] = ptrtoint i8* [[ABEGINV]] to i64
10619f2f3b9dSJoel E. Denny // CK4-DAG: [[BENDI:%.+]] = ptrtoint i8* [[BENDV]] to i64
10629f2f3b9dSJoel E. Denny // CK4-DAG: [[CSIZE:%.+]] = sub i64 [[BENDI]], [[ABEGINI]]
10639f2f3b9dSJoel E. Denny // CK4-DAG: [[CUSIZE:%.+]] = sdiv exact i64 [[CSIZE]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
106460d71a28SAlexey Bataev // CK4-DAG: [[BPTRADDR0BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
10659f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR0BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10669f2f3b9dSJoel E. Denny // CK4-DAG: [[PRESIZE:%.+]] = call i64 @__tgt_mapper_num_components(i8* [[HANDLE]])
10679f2f3b9dSJoel E. Denny // CK4-DAG: [[SHIPRESIZE:%.+]] = shl i64 [[PRESIZE]], 48
106860d71a28SAlexey Bataev // CK4-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 0, [[SHIPRESIZE]]
10699f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
10709f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
10719f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
10729f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
10739f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
10749f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
10759f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
10769f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
10779f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
10789f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
10799f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
10809f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10819f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
10829f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
10839f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
10849f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
10859f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
10869f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
10879f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
10889f2f3b9dSJoel E. Denny // CK4-DAG: [[PHITYPE0:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
1089e4eaf9d8SJoseph Huber // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR0BC]], i8* [[PTRADDR0BC]], i64 [[CUSIZE]], i64 [[PHITYPE0]], {{.*}})
109060d71a28SAlexey Bataev // CK4-DAG: [[BPTRADDR1BC:%.+]] = bitcast %class.C* [[PTR]] to i8*
10919f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR1BC:%.+]] = bitcast i32* [[ABEGIN]] to i8*
10929f2f3b9dSJoel E. Denny // 281474976710659 == 0x1,000,000,003
109360d71a28SAlexey Bataev // CK4-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 281474976710659, [[SHIPRESIZE]]
10949f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
10959f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
10969f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
10979f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
10989f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
10999f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
11009f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
11019f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
11029f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
11039f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
11049f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
11059f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11069f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
11079f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
11089f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
11099f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
11109f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
11119f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11129f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
11139f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE1:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
1114e4eaf9d8SJoseph Huber // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR1BC]], i8* [[PTRADDR1BC]], i64 4, i64 [[TYPE1]], {{.*}})
11159f2f3b9dSJoel E. Denny // CK4-DAG: [[BPTRADDR2BC:%.+]] = bitcast double** [[BBEGIN]] to i8*
11169f2f3b9dSJoel E. Denny // CK4-DAG: [[PTRADDR2BC:%.+]] = bitcast double* [[BARRBEGINGEP]] to i8*
11179f2f3b9dSJoel E. Denny // 281474976710675 == 0x1,000,000,013
111860d71a28SAlexey Bataev // CK4-DAG: [[MEMBERTYPE:%.+]] = add nuw i64 281474976710675, [[SHIPRESIZE]]
11199f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPETF:%.+]] = and i64 [[TYPE]], 3
11209f2f3b9dSJoel E. Denny // CK4-DAG: [[ISALLOC:%.+]] = icmp eq i64 [[TYPETF]], 0
11219f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISALLOC]], label %[[ALLOC:[^,]+]], label %[[ALLOCELSE:[^,]+]]
11229f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOC]]
11239f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCTYPE:%.+]] = and i64 [[MEMBERTYPE]], -4
11249f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND:[^,]+]]
11259f2f3b9dSJoel E. Denny // CK4-DAG: [[ALLOCELSE]]
11269f2f3b9dSJoel E. Denny // CK4-DAG: [[ISTO:%.+]] = icmp eq i64 [[TYPETF]], 1
11279f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISTO]], label %[[TO:[^,]+]], label %[[TOELSE:[^,]+]]
11289f2f3b9dSJoel E. Denny // CK4-DAG: [[TO]]
11299f2f3b9dSJoel E. Denny // CK4-DAG: [[TOTYPE:%.+]] = and i64 [[MEMBERTYPE]], -3
11309f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11319f2f3b9dSJoel E. Denny // CK4-DAG: [[TOELSE]]
11329f2f3b9dSJoel E. Denny // CK4-DAG: [[ISFROM:%.+]] = icmp eq i64 [[TYPETF]], 2
11339f2f3b9dSJoel E. Denny // CK4-DAG: br i1 [[ISFROM]], label %[[FROM:[^,]+]], label %[[TYEND]]
11349f2f3b9dSJoel E. Denny // CK4-DAG: [[FROM]]
11359f2f3b9dSJoel E. Denny // CK4-DAG: [[FROMTYPE:%.+]] = and i64 [[MEMBERTYPE]], -2
11369f2f3b9dSJoel E. Denny // CK4-DAG: br label %[[TYEND]]
11379f2f3b9dSJoel E. Denny // CK4-DAG: [[TYEND]]
11389f2f3b9dSJoel E. Denny // CK4-DAG: [[TYPE2:%.+]] = phi i64 [ [[ALLOCTYPE]], %[[ALLOC]] ], [ [[TOTYPE]], %[[TO]] ], [ [[FROMTYPE]], %[[FROM]] ], [ [[MEMBERTYPE]], %[[TOELSE]] ]
1139e4eaf9d8SJoseph Huber // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTRADDR2BC]], i8* [[PTRADDR2BC]], i64 16, i64 [[TYPE2]], {{.*}})
114060d71a28SAlexey Bataev // CK4: [[PTRNEXT]] = getelementptr %class.C, %class.C* [[PTR]], i32 1
114160d71a28SAlexey Bataev // CK4: [[ISDONE:%.+]] = icmp eq %class.C* [[PTRNEXT]], [[PTREND]]
11429f2f3b9dSJoel E. Denny // CK4: br i1 [[ISDONE]], label %[[LEXIT:[^,]+]], label %[[LBODY]]
11439f2f3b9dSJoel E. Denny
11449f2f3b9dSJoel E. Denny // CK4: [[LEXIT]]
114560d71a28SAlexey Bataev // CK4: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
11469f2f3b9dSJoel E. Denny // CK4: [[TYPEDEL:%.+]] = and i64 [[TYPE]], 8
114760d71a28SAlexey Bataev // CK4: [[ISNOTDEL:%.+]] = icmp ne i64 [[TYPEDEL]], 0
11480caf736dSAlexey Bataev // CK4: [[CMP1:%.+]] = and i1 [[ISARRAY]], [[ISNOTDEL]]
114960d71a28SAlexey Bataev // CK4: br i1 [[CMP1]], label %[[EVALDEL:[^,]+]], label %[[DONE]]
115060d71a28SAlexey Bataev // CK4: [[EVALDEL]]
11519f2f3b9dSJoel E. Denny // CK4-64-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 16
11529f2f3b9dSJoel E. Denny // CK4-32-DAG: [[ARRSIZE:%.+]] = mul nuw i64 [[SIZE]], 8
115307988422SAlexey Bataev
115407988422SAlexey Bataev // Remove movement mappings and mark as implicit
115507988422SAlexey Bataev // CK4-DAG: [[DTYPE:%.+]] = and i64 [[TYPE]], -4
115607988422SAlexey Bataev // CK4-DAG: [[DTYPE1:%.+]] = or i64 [[DTYPE]], 512
115707988422SAlexey Bataev // CK4: call void @__tgt_push_mapper_component(i8* [[HANDLE]], i8* [[BPTR]], i8* [[BEGIN]], i64 [[ARRSIZE]], i64 [[DTYPE1]], {{.*}})
11589f2f3b9dSJoel E. Denny // CK4: br label %[[DONE]]
11599f2f3b9dSJoel E. Denny // CK4: [[DONE]]
11609f2f3b9dSJoel E. Denny // CK4: ret void
11619f2f3b9dSJoel E. Denny
11629f2f3b9dSJoel E. Denny
11639f2f3b9dSJoel E. Denny // CK4-LABEL: define {{.*}}void @{{.*}}foo{{.*}}
foo(int a)11649f2f3b9dSJoel E. Denny void foo(int a){
11659f2f3b9dSJoel E. Denny int i = a;
11669f2f3b9dSJoel E. Denny C c;
11679f2f3b9dSJoel E. Denny c.a = a;
11689f2f3b9dSJoel E. Denny
1169da8bec47SJoseph 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:%.+]])
11709f2f3b9dSJoel E. Denny // CK4-DAG: [[TGEPBP]] = getelementptr inbounds {{.+}}[[TBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11719f2f3b9dSJoel E. Denny // CK4-DAG: [[TGEPP]] = getelementptr inbounds {{.+}}[[TP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11729f2f3b9dSJoel E. Denny // CK4-DAG: [[TMPRGEP]] = bitcast [1 x i8*]* [[TMPR:%[^,]+]] to i8**
11739f2f3b9dSJoel E. Denny // CK4-DAG: [[TBP0:%.+]] = getelementptr inbounds {{.+}}[[TBP]], i{{.+}} 0, i{{.+}} 0
11749f2f3b9dSJoel E. Denny // CK4-DAG: [[TP0:%.+]] = getelementptr inbounds {{.+}}[[TP]], i{{.+}} 0, i{{.+}} 0
11759f2f3b9dSJoel E. Denny // CK4-DAG: [[TMPR1:%.+]] = getelementptr inbounds {{.+}}[[TMPR]], i[[sz]] 0, i[[sz]] 0
11769f2f3b9dSJoel E. Denny // CK4-DAG: [[TCBP0:%.+]] = bitcast i8** [[TBP0]] to %class.C**
11779f2f3b9dSJoel E. Denny // CK4-DAG: [[TCP0:%.+]] = bitcast i8** [[TP0]] to %class.C**
11789f2f3b9dSJoel E. Denny // CK4-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[TCBP0]]
11799f2f3b9dSJoel E. Denny // CK4-DAG: store %class.C* [[VAL]], %class.C** [[TCP0]]
1180e4eaf9d8SJoseph Huber // CK4-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[TMPR1]]
11819f2f3b9dSJoel E. Denny #pragma omp target update to(present, mapper(id): c)
11829f2f3b9dSJoel E. Denny
1183da8bec47SJoseph 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:%.+]])
11849f2f3b9dSJoel E. Denny // CK4-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11859f2f3b9dSJoel E. Denny // CK4-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0
11869f2f3b9dSJoel E. Denny // CK4-DAG: [[FMPRGEP]] = bitcast [1 x i8*]* [[FMPR:%[^,]+]] to i8**
11879f2f3b9dSJoel E. Denny // CK4-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0
11889f2f3b9dSJoel E. Denny // CK4-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0
11899f2f3b9dSJoel E. Denny // CK4-DAG: [[FMPR1:%.+]] = getelementptr inbounds {{.+}}[[FMPR]], i[[sz]] 0, i[[sz]] 0
11909f2f3b9dSJoel E. Denny // CK4-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C**
11919f2f3b9dSJoel E. Denny // CK4-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C**
11929f2f3b9dSJoel E. Denny // CK4-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]]
11939f2f3b9dSJoel E. Denny // CK4-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]]
1194e4eaf9d8SJoseph Huber // CK4-DAG: store i8* bitcast (void (i8*, i8*, i8*, i64, i64, i8*)* [[MPRFUNC]] to i8*), i8** [[FMPR1]]
11959f2f3b9dSJoel E. Denny #pragma omp target update from(mapper(id), present: c)
11969f2f3b9dSJoel E. Denny }
11979f2f3b9dSJoel E. Denny
11989f2f3b9dSJoel E. Denny #endif // CK4
11999f2f3b9dSJoel E. Denny
1200537b16e9SGeorge Rokos #endif // HEADER
1201