blob: 96bdc874ece262484662f71a1d8bb342e276f66f [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,
Alexey Bataeve253f2f2018-05-09 14:15:18 +000020// CHECK-DAG: @globals = global %struct.S zeroinitializer,
Alexey Bataev38235142018-07-31 16:40:15 +000021// CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
22// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
23// CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+42]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+43]]_ctor to i8*)],
24// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000025
Alexey Bataev6d944102018-05-02 15:45:28 +000026// CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
27// CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}})
28// CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}})
Alexey Bataev38235142018-07-31 16:40:15 +000029// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+36]]_ctor()
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000030
31#ifndef HEADER
32#define HEADER
33
Alexey Bataev6d944102018-05-02 15:45:28 +000034template <typename T>
35class TemplateClass {
36 T a;
37public:
38 TemplateClass() {}
39 T f_method() const { return a; }
40};
41
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000042int foo();
43
44int baz1();
45
46int baz2();
47
48int baz4() { return 5; }
49
Alexey Bataevfb388282018-05-01 14:09:46 +000050template <typename T>
51T FA() {
Alexey Bataev6d944102018-05-02 15:45:28 +000052 TemplateClass<T> s;
53 return s.f_method();
Alexey Bataevfb388282018-05-01 14:09:46 +000054}
55
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000056#pragma omp declare target
Alexey Bataevdadf2d12018-04-30 18:09:40 +000057struct S {
58 int a;
59 S(int a) : a(a) {}
60};
61
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000062int foo() { return 0; }
63int b = 15;
64int d;
Alexey Bataeve253f2f2018-05-09 14:15:18 +000065S globals(d);
Alexey Bataev2f5b2672018-07-27 17:37:32 +000066static S stat(d);
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000067#pragma omp end declare target
68int c;
69
70int bar() { return 1 + foo() + bar() + baz1() + baz2(); }
71
72int maini1() {
73 int a;
74 static long aa = 32;
Alexey Bataev9a700172018-05-08 14:16:57 +000075// CHECK-DAG: define weak void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](i32* dereferenceable{{.*}}, i64 {{.*}}, i64 {{.*}})
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000076#pragma omp target map(tofrom \
Alexey Bataev2c1dffe2018-04-16 20:34:41 +000077 : a, b)
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000078 {
Alexey Bataevdadf2d12018-04-30 18:09:40 +000079 S s(a);
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000080 static long aaa = 23;
Alexey Bataevfb388282018-05-01 14:09:46 +000081 a = foo() + bar() + b + c + d + aa + aaa + FA<int>();
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000082 }
83 return baz4();
84}
85
Alexey Bataevfb388282018-05-01 14:09:46 +000086int baz3() { return 2 + baz2(); }
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000087int baz2() {
Alexey Bataev9a700172018-05-08 14:16:57 +000088// CHECK-DAG: define weak void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](i64 {{.*}})
Alexey Bataev4ac68a22018-05-16 15:08:32 +000089#pragma omp target parallel
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000090 ++c;
91 return 2 + baz3();
92}
Alexey Bataev4f4bf7c2018-03-15 15:47:20 +000093
94// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
95#endif // HEADER