Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1 | ///==========================================================================/// |
| 2 | // RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s |
| 3 | // RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s |
| 4 | // 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 -allow-deprecated-dag-overlap %s |
| 5 | // RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s |
| 6 | // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s |
| 7 | // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s |
| 8 | |
| 9 | // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s |
| 10 | // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s |
| 11 | // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s |
| 12 | // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s |
| 13 | // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s |
| 14 | // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s |
| 15 | |
| 16 | // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} |
| 17 | |
| 18 | // expected-no-diagnostics |
| 19 | #ifndef HEADER |
| 20 | #define HEADER |
| 21 | |
| 22 | class C { |
| 23 | public: |
| 24 | int a; |
| 25 | }; |
| 26 | |
| 27 | #pragma omp declare mapper(id: C s) map(s.a) |
| 28 | |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 29 | // CHECK-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l54.region_id = weak constant i8 0 |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 30 | |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 31 | // CHECK: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4] |
| 32 | // CHECK: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 35] |
| 33 | // CHECK: [[TSIZES:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4] |
| 34 | // CHECK: [[TTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 33] |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 35 | // CHECK: [[FSIZES:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4] |
| 36 | // CHECK: [[FTYPES:@.+]] = {{.+}}constant [1 x i64] [i64 34] |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 37 | |
| 38 | // CHECK-LABEL: foo{{.*}}( |
| 39 | void foo(int a){ |
| 40 | int i = a; |
| 41 | C c; |
| 42 | c.a = a; |
| 43 | |
| 44 | // CHECK-DAG: call i32 @__tgt_target(i64 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}}) |
| 45 | // CHECK-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0 |
| 46 | // CHECK-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0 |
| 47 | // CHECK-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0 |
| 48 | // CHECK-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0 |
| 49 | // CHECK-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to %class.C** |
| 50 | // CHECK-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to %class.C** |
| 51 | // CHECK-DAG: store %class.C* [[VAL:%[^,]+]], %class.C** [[CBP1]] |
| 52 | // CHECK-DAG: store %class.C* [[VAL]], %class.C** [[CP1]] |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 53 | // CHECK: call void [[KERNEL:@.+]](%class.C* [[VAL]]) |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 54 | #pragma omp target map(mapper(id),tofrom: c) |
| 55 | { |
| 56 | ++c.a; |
| 57 | } |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 58 | |
| 59 | // CHECK-DAG: call void @__tgt_target_data_update(i64 -1, i32 1, i8** [[TGEPBP:%.+]], i8** [[TGEPP:%.+]], i[[sz]]* getelementptr {{.+}}[1 x i[[sz]]]* [[TSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[TTYPES]]{{.+}}) |
| 60 | // CHECK-DAG: [[TGEPBP]] = getelementptr inbounds {{.+}}[[TBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0 |
| 61 | // CHECK-DAG: [[TGEPP]] = getelementptr inbounds {{.+}}[[TP:%[^,]+]], i{{.+}} 0, i{{.+}} 0 |
| 62 | // CHECK-DAG: [[TBP0:%.+]] = getelementptr inbounds {{.+}}[[TBP]], i{{.+}} 0, i{{.+}} 0 |
| 63 | // CHECK-DAG: [[TP0:%.+]] = getelementptr inbounds {{.+}}[[TP]], i{{.+}} 0, i{{.+}} 0 |
| 64 | // CHECK-DAG: [[TCBP0:%.+]] = bitcast i8** [[TBP0]] to %class.C** |
| 65 | // CHECK-DAG: [[TCP0:%.+]] = bitcast i8** [[TP0]] to %class.C** |
| 66 | // CHECK-DAG: store %class.C* [[VAL]], %class.C** [[TCBP0]] |
| 67 | // CHECK-DAG: store %class.C* [[VAL]], %class.C** [[TCP0]] |
| 68 | #pragma omp target update to(mapper(id): c) |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 69 | |
| 70 | // CHECK-DAG: call void @__tgt_target_data_update(i64 -1, i32 1, i8** [[FGEPBP:%.+]], i8** [[FGEPP:%.+]], i[[sz]]* getelementptr {{.+}}[1 x i[[sz]]]* [[FSIZES]], i32 0, i32 0), {{.+}}getelementptr {{.+}}[1 x i64]* [[FTYPES]]{{.+}}) |
| 71 | // CHECK-DAG: [[FGEPBP]] = getelementptr inbounds {{.+}}[[FBP:%[^,]+]], i{{.+}} 0, i{{.+}} 0 |
| 72 | // CHECK-DAG: [[FGEPP]] = getelementptr inbounds {{.+}}[[FP:%[^,]+]], i{{.+}} 0, i{{.+}} 0 |
| 73 | // CHECK-DAG: [[FBP0:%.+]] = getelementptr inbounds {{.+}}[[FBP]], i{{.+}} 0, i{{.+}} 0 |
| 74 | // CHECK-DAG: [[FP0:%.+]] = getelementptr inbounds {{.+}}[[FP]], i{{.+}} 0, i{{.+}} 0 |
| 75 | // CHECK-DAG: [[FCBP0:%.+]] = bitcast i8** [[FBP0]] to %class.C** |
| 76 | // CHECK-DAG: [[FCP0:%.+]] = bitcast i8** [[FP0]] to %class.C** |
| 77 | // CHECK-DAG: store %class.C* [[VAL]], %class.C** [[FCBP0]] |
| 78 | // CHECK-DAG: store %class.C* [[VAL]], %class.C** [[FCP0]] |
| 79 | #pragma omp target update from(mapper(id): c) |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | |
| 83 | // CHECK: define internal void [[KERNEL]](%class.C* {{.+}}[[ARG:%.+]]) |
| 84 | // CHECK: [[ADDR:%.+]] = alloca %class.C*, |
| 85 | // CHECK: store %class.C* [[ARG]], %class.C** [[ADDR]] |
| 86 | // CHECK: [[CADDR:%.+]] = load %class.C*, %class.C** [[ADDR]] |
| 87 | // CHECK: [[CAADDR:%.+]] = getelementptr inbounds %class.C, %class.C* [[CADDR]], i32 0, i32 0 |
| 88 | // CHECK: [[VAL:%[^,]+]] = load i32, i32* [[CAADDR]] |
| 89 | // CHECK: {{.+}} = add nsw i32 [[VAL]], 1 |
| 90 | // CHECK: } |
| 91 | |
| 92 | #endif |