Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_map_member_expr_array_section_codegen.cpp
blob3c37f2bdeaf5e1f01544cb6eba464f67f20c6369
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -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 -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
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];
21 template <typename T>
22 struct maptest {
23 S<T> s;
24 maptest() {
25 // CHECK: [[BPTRS:%.+]] = alloca [2 x ptr],
26 // CHECK: [[PTRS:%.+]] = alloca [2 x ptr],
27 // CHECK: [[SIZES:%.+]] = alloca [2 x i64],
28 // CHECK: getelementptr inbounds
29 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, ptr [[THIS:%.+]], i32 0, i32 0
30 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, ptr [[S_ADDR]], i32 0, i32 0
31 // CHECK: [[S_DATA_0_ADDR:%.+]] = getelementptr inbounds [6 x float], ptr [[S_DATA_ADDR]], i64 0, i64 0
33 // SZ = &this->s.data[6]-&this->s.data[0]
34 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, ptr [[THIS]], i32 0, i32 0
35 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, ptr [[S_ADDR]], i32 0, i32 0
36 // CHECK: [[S_DATA_5_ADDR:%.+]] = getelementptr inbounds [6 x float], ptr [[S_DATA_ADDR]], i64 0, i64 5
37 // CHECK: [[S_DATA_6_ADDR:%.+]] = getelementptr float, ptr [[S_DATA_5_ADDR]], i32 1
38 // CHECK: [[END_BC:%.+]] = ptrtoint ptr [[S_DATA_6_ADDR]] to i64
39 // CHECK: [[BEG_BC:%.+]] = ptrtoint ptr [[S_DATA_0_ADDR]] to i64
40 // CHECK: [[DIFF:%.+]] = sub i64 [[END_BC]], [[BEG_BC]]
41 // CHECK: [[SZ:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64)
43 // Fill mapping arrays
44 // CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 0
45 // CHECK: store ptr [[THIS]], ptr [[BPTR0]],
46 // CHECK: [[PTR0:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 0
47 // CHECK: store ptr [[S_DATA_0_ADDR]], ptr [[PTR0]],
48 // CHECK: [[SIZE0:%.+]] = getelementptr inbounds [2 x i64], ptr [[SIZES]], i32 0, i32 0
49 // CHECK: store i64 [[SZ]], ptr [[SIZE0]],
50 // CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 1
51 // CHECK: store ptr [[THIS]], ptr [[BPTR1]],
52 // CHECK: [[PTR1:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 1
53 // CHECK: store ptr [[S_DATA_0_ADDR]], ptr [[PTR1]],
54 // CHECK: [[BPTR:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 0
55 // CHECK: [[PTR:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 0
56 // CHECK: [[SIZE:%.+]] = getelementptr inbounds [2 x i64], ptr [[SIZES]], i32 0, i32 0
57 // CHECK: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 -1, i32 2, ptr [[BPTR]], ptr [[PTR]], ptr [[SIZE]], ptr [[MAP_ENTER]], ptr null, ptr null)
58 #pragma omp target enter data map(alloc : s.data[:6])
61 ~maptest() {
62 // CHECK: [[BPTRS:%.+]] = alloca [2 x ptr],
63 // CHECK: [[PTRS:%.+]] = alloca [2 x ptr],
64 // CHECK: [[SIZE:%.+]] = alloca [2 x i64],
65 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, ptr [[THIS:%.+]], i32 0, i32 0
66 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, ptr [[S_ADDR]], i32 0, i32 0
67 // CHECK: [[S_DATA_0_ADDR:%.+]] = getelementptr inbounds [6 x float], ptr [[S_DATA_ADDR]], i64 0, i64 0
69 // SZ = &this->s.data[6]-&this->s.data[0]
70 // CHECK: [[S_ADDR:%.+]] = getelementptr inbounds %struct.maptest, ptr [[THIS]], i32 0, i32 0
71 // CHECK: [[S_DATA_ADDR:%.+]] = getelementptr inbounds %struct.S, ptr [[S_ADDR]], i32 0, i32 0
72 // CHECK: [[S_DATA_5_ADDR:%.+]] = getelementptr inbounds [6 x float], ptr [[S_DATA_ADDR]], i64 0, i64 5
73 // CHECK: [[S_DATA_6_ADDR:%.+]] = getelementptr float, ptr [[S_DATA_5_ADDR]], i32 1
74 // CHECK: [[END_BC:%.+]] = ptrtoint ptr [[S_DATA_6_ADDR]] to i64
75 // CHECK: [[BEG_BC:%.+]] = ptrtoint ptr [[S_DATA_0_ADDR]] to i64
76 // CHECK: [[DIFF:%.+]] = sub i64 [[END_BC]], [[BEG_BC]]
77 // CHECK: [[SZ:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64)
79 // Fill mapping arrays
80 // CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 0
81 // CHECK: store ptr [[THIS]], ptr [[BPTR0]],
82 // CHECK: [[PTR0:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 0
83 // CHECK: store ptr [[S_DATA_0_ADDR]], ptr [[PTR0]],
84 // CHECK: [[SIZE0:%.+]] = getelementptr inbounds [2 x i64], ptr [[SIZES]], i32 0, i32 0
85 // CHECK: store i64 [[SZ]], ptr [[SIZE0]],
86 // CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 1
87 // CHECK: store ptr [[THIS]], ptr [[BPTR1]],
88 // CHECK: [[PTR1:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 1
89 // CHECK: store ptr [[S_DATA_0_ADDR]], ptr [[PTR1]],
90 // CHECK: [[BPTR:%.+]] = getelementptr inbounds [2 x ptr], ptr [[BPTRS]], i32 0, i32 0
91 // CHECK: [[PTR:%.+]] = getelementptr inbounds [2 x ptr], ptr [[PTRS]], i32 0, i32 0
92 // CHECK: [[SIZE:%.+]] = getelementptr inbounds [2 x i64], ptr [[SIZES]], i32 0, i32 0
93 // CHECK: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 -1, i32 2, ptr [[BPTR]], ptr [[PTR]], ptr [[SIZE]], ptr [[MAP_EXIT]], ptr null, ptr null)
94 #pragma omp target exit data map(delete : s.data[:6])
98 maptest<float> a;
100 #endif