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, |
Alexey Bataev | e253f2f | 2018-05-09 14:15:18 +0000 | [diff] [blame] | 20 | // CHECK-DAG: @globals = global %struct.S zeroinitializer, |
Alexey Bataev | 3823514 | 2018-07-31 16:40:15 +0000 | [diff] [blame] | 21 | // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer, |
| 22 | // CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]] |
Alexey Bataev | bf8fe71 | 2018-08-07 16:14:36 +0000 | [diff] [blame] | 23 | // CHECK-DAG: @out_decl_target = global i32 0, |
| 24 | // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+56]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+57]]_ctor to i8*)], |
Alexey Bataev | 3823514 | 2018-07-31 16:40:15 +0000 | [diff] [blame] | 25 | // CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)], |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 26 | |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 27 | // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}() |
| 28 | // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}}) |
| 29 | // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}}) |
Alexey Bataev | bf8fe71 | 2018-08-07 16:14:36 +0000 | [diff] [blame] | 30 | // CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+50]]_ctor() |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 31 | |
| 32 | #ifndef HEADER |
| 33 | #define HEADER |
| 34 | |
Alexey Bataev | bf8fe71 | 2018-08-07 16:14:36 +0000 | [diff] [blame] | 35 | int out_decl_target = 0; |
| 36 | #pragma omp declare target |
| 37 | void lambda () { |
| 38 | #ifdef __cpp_lambdas |
| 39 | (void)[&] { (void)out_decl_target; }; |
| 40 | #else |
| 41 | #pragma clang __debug captured |
| 42 | { |
| 43 | (void)out_decl_target; |
| 44 | } |
| 45 | #endif |
| 46 | }; |
| 47 | #pragma omp end declare target |
| 48 | |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 49 | template <typename T> |
| 50 | class TemplateClass { |
| 51 | T a; |
| 52 | public: |
| 53 | TemplateClass() {} |
| 54 | T f_method() const { return a; } |
| 55 | }; |
| 56 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 57 | int foo(); |
| 58 | |
| 59 | int baz1(); |
| 60 | |
| 61 | int baz2(); |
| 62 | |
| 63 | int baz4() { return 5; } |
| 64 | |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 65 | template <typename T> |
| 66 | T FA() { |
Alexey Bataev | 6d94410 | 2018-05-02 15:45:28 +0000 | [diff] [blame] | 67 | TemplateClass<T> s; |
| 68 | return s.f_method(); |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 71 | #pragma omp declare target |
Alexey Bataev | dadf2d1 | 2018-04-30 18:09:40 +0000 | [diff] [blame] | 72 | struct S { |
| 73 | int a; |
| 74 | S(int a) : a(a) {} |
| 75 | }; |
| 76 | |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 77 | int foo() { return 0; } |
| 78 | int b = 15; |
| 79 | int d; |
Alexey Bataev | e253f2f | 2018-05-09 14:15:18 +0000 | [diff] [blame] | 80 | S globals(d); |
Alexey Bataev | 2f5b267 | 2018-07-27 17:37:32 +0000 | [diff] [blame] | 81 | static S stat(d); |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 82 | #pragma omp end declare target |
| 83 | int c; |
| 84 | |
| 85 | int bar() { return 1 + foo() + bar() + baz1() + baz2(); } |
| 86 | |
| 87 | int maini1() { |
| 88 | int a; |
| 89 | static long aa = 32; |
Alexey Bataev | 9a70017 | 2018-05-08 14:16:57 +0000 | [diff] [blame] | 90 | // CHECK-DAG: define weak void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](i32* dereferenceable{{.*}}, i64 {{.*}}, i64 {{.*}}) |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 91 | #pragma omp target map(tofrom \ |
Alexey Bataev | 2c1dffe | 2018-04-16 20:34:41 +0000 | [diff] [blame] | 92 | : a, b) |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 93 | { |
Alexey Bataev | dadf2d1 | 2018-04-30 18:09:40 +0000 | [diff] [blame] | 94 | S s(a); |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 95 | static long aaa = 23; |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 96 | a = foo() + bar() + b + c + d + aa + aaa + FA<int>(); |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 97 | } |
| 98 | return baz4(); |
| 99 | } |
| 100 | |
Alexey Bataev | fb38828 | 2018-05-01 14:09:46 +0000 | [diff] [blame] | 101 | int baz3() { return 2 + baz2(); } |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 102 | int baz2() { |
Alexey Bataev | 9a70017 | 2018-05-08 14:16:57 +0000 | [diff] [blame] | 103 | // CHECK-DAG: define weak void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](i64 {{.*}}) |
Alexey Bataev | 4ac68a2 | 2018-05-16 15:08:32 +0000 | [diff] [blame] | 104 | #pragma omp target parallel |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 105 | ++c; |
| 106 | return 2 + baz3(); |
| 107 | } |
Alexey Bataev | 4f4bf7c | 2018-03-15 15:47:20 +0000 | [diff] [blame] | 108 | |
| 109 | // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}} |
| 110 | #endif // HEADER |