blob: ce194ef0e8b55f6012d459f8a830e4742acdc8e8 [file] [log] [blame]
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +00001// 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 Bataev6d944102018-05-02 15:45:28 +000021// 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 Bataev4f4bf7c2018-03-15 15:47:20 +000024
25#ifndef HEADER
26#define HEADER
27
Alexey Bataev6d944102018-05-02 15:45:28 +000028template <typename T>
29class TemplateClass {
30 T a;
31public:
32 TemplateClass() {}
33 T f_method() const { return a; }
34};
35
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000036int foo();
37
38int baz1();
39
40int baz2();
41
42int baz4() { return 5; }
43
Alexey Bataevfb388282018-05-01 14:09:46 +000044template <typename T>
45T FA() {
Alexey Bataev6d944102018-05-02 15:45:28 +000046 TemplateClass<T> s;
47 return s.f_method();
Alexey Bataevfb388282018-05-01 14:09:46 +000048}
49
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000050#pragma omp declare target
Alexey Bataevdadf2d12018-04-30 18:09:40 +000051struct S {
52 int a;
53 S(int a) : a(a) {}
54};
55
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000056int foo() { return 0; }
57int b = 15;
58int d;
59#pragma omp end declare target
60int c;
61
62int bar() { return 1 + foo() + bar() + baz1() + baz2(); }
63
64int 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 Bataev2c1dffe2018-04-16 20:34:41 +000069 : a, b)
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000070 {
Alexey Bataevdadf2d12018-04-30 18:09:40 +000071 S s(a);
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000072 static long aaa = 23;
Alexey Bataevfb388282018-05-01 14:09:46 +000073 a = foo() + bar() + b + c + d + aa + aaa + FA<int>();
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000074 }
75 return baz4();
76}
77
Alexey Bataevfb388282018-05-01 14:09:46 +000078int baz3() { return 2 + baz2(); }
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000079int 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 Bataev4f4bf7c2018-03-15 15:47:20 +000085
86// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
87#endif // HEADER