Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc |
| 2 | // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s |
| 3 | // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t |
| 4 | // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - | FileCheck %s |
| 5 | |
| 6 | // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc |
| 7 | // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o -| FileCheck %s --check-prefix SIMD-ONLY |
| 8 | // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t |
| 9 | // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -o - | FileCheck %s --check-prefix SIMD-ONLY |
| 10 | |
| 11 | // expected-no-diagnostics |
| 12 | |
| 13 | // SIMD-ONLY-NOT: {{__kmpc|__tgt}} |
| 14 | |
| 15 | // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}} |
| 16 | // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23, |
| 17 | // CHECK-DAG: @b = global i32 15, |
| 18 | // CHECK-DAG: @d = global i32 0, |
| 19 | // CHECK-DAG: @c = external global i32, |
| 20 | |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 21 | // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}() |
| 22 | // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}}) |
| 23 | // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}}) |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 24 | |
| 25 | #ifndef HEADER |
| 26 | #define HEADER |
| 27 | |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 28 | template <typename T> |
| 29 | class TemplateClass { |
| 30 | T a; |
| 31 | public: |
| 32 | TemplateClass() {} |
| 33 | T f_method() const { return a; } |
| 34 | }; |
| 35 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 36 | int foo(); |
| 37 | |
| 38 | int baz1(); |
| 39 | |
| 40 | int baz2(); |
| 41 | |
| 42 | int baz4() { return 5; } |
| 43 | |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 44 | template <typename T> |
| 45 | T FA() { |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 46 | TemplateClass<T> s; |
| 47 | return s.f_method(); |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 50 | #pragma omp declare target |
Alexey Bataev | dadf2d1 | 2018-04-30 18:09:40 +0000 | [diff] [blame] | 51 | struct S { |
| 52 | int a; |
| 53 | S(int a) : a(a) {} |
| 54 | }; |
| 55 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 56 | int foo() { return 0; } |
| 57 | int b = 15; |
| 58 | int d; |
| 59 | #pragma omp end declare target |
| 60 | int c; |
| 61 | |
| 62 | int bar() { return 1 + foo() + bar() + baz1() + baz2(); } |
| 63 | |
| 64 | int maini1() { |
| 65 | int a; |
| 66 | static long aa = 32; |
| 67 | // CHECK-DAG: define void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](i32* dereferenceable{{.*}}, i64 {{.*}}, i64 {{.*}}) |
| 68 | #pragma omp target map(tofrom \ |
Alexey Bataev | 2c1dffe | 2018-04-16 20:34:41 +0000 | [diff] [blame] | 69 | : a, b) |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 70 | { |
Alexey Bataev | dadf2d1 | 2018-04-30 18:09:40 +0000 | [diff] [blame] | 71 | S s(a); |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 72 | static long aaa = 23; |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 73 | a = foo() + bar() + b + c + d + aa + aaa + FA<int>(); |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 74 | } |
| 75 | return baz4(); |
| 76 | } |
| 77 | |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 78 | int baz3() { return 2 + baz2(); } |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 79 | int baz2() { |
| 80 | // CHECK-DAG: define void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](i64 {{.*}}) |
| 81 | #pragma omp target |
| 82 | ++c; |
| 83 | return 2 + baz3(); |
| 84 | } |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 85 | |
| 86 | // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}} |
| 87 | #endif // HEADER |