1 // RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s 2 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s 3 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 4 // expected-no-diagnostics 5 #ifndef HEADER 6 #define HEADER 7 8 // CHECK: [[SIZE_ENTER:@.+]] = private unnamed_addr constant [2 x i64] [i64 0, i64 24] 9 // 0 = OMP_MAP_NONE 10 // 281474976710656 = 0x1000000000000 = OMP_MAP_MEMBER_OF of 1-st element 11 // CHECK: [[MAP_ENTER:@.+]] = private unnamed_addr constant [2 x i64] [i64 0, i64 281474976710656] 12 // CHECK: [[SIZE_EXIT:@.+]] = private unnamed_addr constant [2 x i64] [i64 0, i64 24] 13 // 281474976710664 = 0x1000000000008 = OMP_MAP_MEMBER_OF of 1-st element | OMP_MAP_DELETE 14 // CHECK: [[MAP_EXIT:@.+]] = private unnamed_addr constant [2 x i64] [i64 0, i64 281474976710664] 15 template <typename T> 16 struct S { 17 constexpr static int size = 6; 18 T data[size]; 19 }; 20 21 template <typename T> 22 struct maptest { 23 S<T> s; maptestmaptest24 maptest() { 25 // CHECK: [[BPTRS:%.+]] = alloca [2 x i8*], 26 // CHECK: [[PTRS:%.+]] = alloca [2 x i8*], 27 // CHECK: [[SIZES:%.+]] = alloca [2 x i64], 28 // CHECK: getelementptr inbounds 29 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, %struct.maptest* [[THIS:%.+]], i32 0, i32 0 30 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_ADDR]], i32 0, i32 0 31 // CHECK: [[S_DATA_0_ADDR:%.+]] = getelementptr inbounds [6 x float], [6 x float]* [[S_DATA_ADDR]], i64 0, i64 0 32 33 // SZ = &this->s.data[6]-&this->s.data[0] 34 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, %struct.maptest* [[THIS]], i32 0, i32 0 35 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_ADDR]], i32 0, i32 0 36 // CHECK: [[S_DATA_5_ADDR:%.+]] = getelementptr inbounds [6 x float], [6 x float]* [[S_DATA_ADDR]], i64 0, i64 5 37 // CHECK: [[S_DATA_6_ADDR:%.+]] = getelementptr float, float* [[S_DATA_5_ADDR]], i32 1 38 // CHECK: [[BEG:%.+]] = bitcast float* [[S_DATA_0_ADDR]] to i8* 39 // CHECK: [[END:%.+]] = bitcast float* [[S_DATA_6_ADDR]] to i8* 40 // CHECK: [[END_BC:%.+]] = ptrtoint i8* [[END]] to i64 41 // CHECK: [[BEG_BC:%.+]] = ptrtoint i8* [[BEG]] to i64 42 // CHECK: [[DIFF:%.+]] = sub i64 [[END_BC]], [[BEG_BC]] 43 // CHECK: [[SZ:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64) 44 45 // Fill mapping arrays 46 // CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 0 47 // CHECK: [[BPTR0_THIS:%.+]] = bitcast i8** [[BPTR0]] to %struct.maptest** 48 // CHECK: store %struct.maptest* [[THIS]], %struct.maptest** [[BPTR0_THIS]], 49 // CHECK: [[PTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 0 50 // CHECK: [[PTR0_DATA:%.+]] = bitcast i8** [[PTR0]] to float** 51 // CHECK: store float* [[S_DATA_0_ADDR]], float** [[PTR0_DATA]], 52 // CHECK: [[SIZE0:%.+]] = getelementptr inbounds [2 x i64], [2 x i64]* [[SIZES]], i32 0, i32 0 53 // CHECK: store i64 [[SZ]], i64* [[SIZE0]], 54 // CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 1 55 // CHECK: [[BPTR1_THIS:%.+]] = bitcast i8** [[BPTR1]] to %struct.maptest** 56 // CHECK: store %struct.maptest* [[THIS]], %struct.maptest** [[BPTR1_THIS]], 57 // CHECK: [[PTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 1 58 // CHECK: [[PTR1_DATA:%.+]] = bitcast i8** [[PTR1]] to float** 59 // CHECK: store float* [[S_DATA_0_ADDR]], float** [[PTR1_DATA]], 60 // CHECK: [[BPTR:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 0 61 // CHECK: [[PTR:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 0 62 // CHECK: [[SIZE:%.+]] = getelementptr inbounds [2 x i64], [2 x i64]* [[SIZES]], i32 0, i32 0 63 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 2, i8** [[BPTR]], i8** [[PTR]], i64* [[SIZE]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAP_ENTER]], i32 0, i32 0), i8** null, i8** null) 64 #pragma omp target enter data map(alloc : s.data[:6]) 65 } 66 ~maptestmaptest67 ~maptest() { 68 // CHECK: [[BPTRS:%.+]] = alloca [2 x i8*], 69 // CHECK: [[PTRS:%.+]] = alloca [2 x i8*], 70 // CHECK: [[SIZE:%.+]] = alloca [2 x i64], 71 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, %struct.maptest* [[THIS:%.+]], i32 0, i32 0 72 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_ADDR]], i32 0, i32 0 73 // CHECK: [[S_DATA_0_ADDR:%.+]] = getelementptr inbounds [6 x float], [6 x float]* [[S_DATA_ADDR]], i64 0, i64 0 74 75 // SZ = &this->s.data[6]-&this->s.data[0] 76 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, %struct.maptest* [[THIS]], i32 0, i32 0 77 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_ADDR]], i32 0, i32 0 78 // CHECK: [[S_DATA_5_ADDR:%.+]] = getelementptr inbounds [6 x float], [6 x float]* [[S_DATA_ADDR]], i64 0, i64 5 79 // CHECK: [[S_DATA_6_ADDR:%.+]] = getelementptr float, float* [[S_DATA_5_ADDR]], i32 1 80 // CHECK: [[BEG:%.+]] = bitcast float* [[S_DATA_0_ADDR]] to i8* 81 // CHECK: [[END:%.+]] = bitcast float* [[S_DATA_6_ADDR]] to i8* 82 // CHECK: [[END_BC:%.+]] = ptrtoint i8* [[END]] to i64 83 // CHECK: [[BEG_BC:%.+]] = ptrtoint i8* [[BEG]] to i64 84 // CHECK: [[DIFF:%.+]] = sub i64 [[END_BC]], [[BEG_BC]] 85 // CHECK: [[SZ:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64) 86 87 // Fill mapping arrays 88 // CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 0 89 // CHECK: [[BPTR0_THIS:%.+]] = bitcast i8** [[BPTR0]] to %struct.maptest** 90 // CHECK: store %struct.maptest* [[THIS]], %struct.maptest** [[BPTR0_THIS]], 91 // CHECK: [[PTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 0 92 // CHECK: [[PTR0_DATA:%.+]] = bitcast i8** [[PTR0]] to float** 93 // CHECK: store float* [[S_DATA_0_ADDR]], float** [[PTR0_DATA]], 94 // CHECK: [[SIZE0:%.+]] = getelementptr inbounds [2 x i64], [2 x i64]* [[SIZES]], i32 0, i32 0 95 // CHECK: store i64 [[SZ]], i64* [[SIZE0]], 96 // CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 1 97 // CHECK: [[BPTR1_THIS:%.+]] = bitcast i8** [[BPTR1]] to %struct.maptest** 98 // CHECK: store %struct.maptest* [[THIS]], %struct.maptest** [[BPTR1_THIS]], 99 // CHECK: [[PTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 1 100 // CHECK: [[PTR1_DATA:%.+]] = bitcast i8** [[PTR1]] to float** 101 // CHECK: store float* [[S_DATA_0_ADDR]], float** [[PTR1_DATA]], 102 // CHECK: [[BPTR:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BPTRS]], i32 0, i32 0 103 // CHECK: [[PTR:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTRS]], i32 0, i32 0 104 // CHECK: [[SIZE:%.+]] = getelementptr inbounds [2 x i64], [2 x i64]* [[SIZES]], i32 0, i32 0 105 // CHECK: call void @__tgt_target_data_end_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 2, i8** [[BPTR]], i8** [[PTR]], i64* [[SIZE]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAP_EXIT]], i32 0, i32 0), i8** null, i8** null) 106 #pragma omp target exit data map(delete : s.data[:6]) 107 } 108 }; 109 110 maptest<float> a; 111 112 #endif 113