2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DLOAD
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DLOAD | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DLOAD | FileCheck %s
|
2018-03-15 23:47:20 +08:00
|
|
|
|
2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix HOST5
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DOMP5
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck %s --check-prefix DEV5
|
2019-08-24 00:11:14 +08:00
|
|
|
|
2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix KMPC-ONLY
|
2019-09-23 23:53:51 +08:00
|
|
|
|
2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix SIMD-ONLY
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DOMP5
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck %s --check-prefix SIMD-ONLY
|
2019-08-24 00:11:14 +08:00
|
|
|
|
2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=45
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=45 | FileCheck %s --check-prefix SIMD-ONLY
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=45
|
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fvisibility protected -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -o - -fopenmp-version=45 | FileCheck %s --check-prefix SIMD-ONLY
|
2018-03-15 23:47:20 +08:00
|
|
|
|
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
// SIMD-ONLY-NOT: {{__kmpc|__tgt}}
|
2019-09-23 23:53:51 +08:00
|
|
|
// KMPC-ONLY-NOT: __tgt
|
2018-03-15 23:47:20 +08:00
|
|
|
|
2018-11-08 03:11:14 +08:00
|
|
|
// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
|
2018-09-07 01:56:28 +08:00
|
|
|
// CHECK-DAG: Bake
|
2018-08-16 03:45:12 +08:00
|
|
|
// CHECK-NOT: @{{hhh|ggg|fff|eee}} =
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @flag = protected global i8 undef,
|
2018-08-16 03:45:12 +08:00
|
|
|
// CHECK-DAG: @aaa = external global i32,
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @bbb ={{ protected | }}global i32 0,
|
2019-03-13 04:05:17 +08:00
|
|
|
// CHECK-DAG: weak constant %struct.__tgt_offload_entry { i8* bitcast (i32* @bbb to i8*),
|
2018-08-16 03:45:12 +08:00
|
|
|
// CHECK-DAG: @ccc = external global i32,
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @ddd ={{ protected | }}global i32 0,
|
2019-08-02 05:15:58 +08:00
|
|
|
// CHECK-DAG: @hhh_decl_tgt_ref_ptr = weak global i32* null
|
|
|
|
// CHECK-DAG: @ggg_decl_tgt_ref_ptr = weak global i32* null
|
|
|
|
// CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null
|
|
|
|
// CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null
|
2018-03-15 23:47:20 +08:00
|
|
|
// CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
|
2021-04-21 15:27:32 +08:00
|
|
|
// CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @_ZN2SS3SSSE ={{ protected | }}global i32 1,
|
|
|
|
// CHECK-DAG: @b ={{ protected | }}global i32 15,
|
|
|
|
// CHECK-DAG: @d ={{ protected | }}global i32 0,
|
2018-03-15 23:47:20 +08:00
|
|
|
// CHECK-DAG: @c = external global i32,
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @globals ={{ protected | }}global %struct.S zeroinitializer,
|
2018-08-01 00:40:15 +08:00
|
|
|
// CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
|
|
|
|
// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
|
2022-01-21 01:06:47 +08:00
|
|
|
// CHECK-DAG: @out_decl_target ={{ protected | }}global i32 0,
|
2018-08-01 00:40:15 +08:00
|
|
|
// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
|
2018-03-15 23:47:20 +08:00
|
|
|
|
2018-05-02 23:45:28 +08:00
|
|
|
// CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
|
|
|
|
// CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
|
2019-08-24 00:11:14 +08:00
|
|
|
// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+78]]_ctor()
|
2018-03-15 23:47:20 +08:00
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
2019-03-13 04:05:17 +08:00
|
|
|
#pragma omp declare target
|
2021-03-25 04:21:43 +08:00
|
|
|
bool flag [[clang::loader_uninitialized]];
|
2019-03-13 04:05:17 +08:00
|
|
|
extern int bbb;
|
|
|
|
#pragma omp end declare target
|
|
|
|
#pragma omp declare target
|
|
|
|
extern int bbb;
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
2018-08-16 03:45:12 +08:00
|
|
|
#pragma omp declare target
|
|
|
|
extern int aaa;
|
|
|
|
int bbb = 0;
|
|
|
|
extern int ccc;
|
|
|
|
int ddd = 0;
|
|
|
|
#pragma omp end declare target
|
2019-03-13 04:05:17 +08:00
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
extern int bbb;
|
|
|
|
#pragma omp end declare target
|
2018-08-16 03:45:12 +08:00
|
|
|
|
|
|
|
extern int eee;
|
|
|
|
int fff = 0;
|
|
|
|
extern int ggg;
|
|
|
|
int hhh = 0;
|
|
|
|
#pragma omp declare target link(eee, fff, ggg, hhh)
|
|
|
|
|
2018-08-08 00:14:36 +08:00
|
|
|
int out_decl_target = 0;
|
2019-08-24 00:11:14 +08:00
|
|
|
#ifdef OMP5
|
|
|
|
#pragma omp declare target(out_decl_target)
|
|
|
|
#endif
|
|
|
|
|
2018-08-08 00:14:36 +08:00
|
|
|
#pragma omp declare target
|
|
|
|
void lambda () {
|
|
|
|
#ifdef __cpp_lambdas
|
|
|
|
(void)[&] { (void)out_decl_target; };
|
|
|
|
#else
|
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
|
|
|
(void)out_decl_target;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
2018-05-02 23:45:28 +08:00
|
|
|
template <typename T>
|
|
|
|
class TemplateClass {
|
|
|
|
T a;
|
|
|
|
public:
|
|
|
|
TemplateClass() {}
|
|
|
|
T f_method() const { return a; }
|
|
|
|
};
|
|
|
|
|
2018-03-15 23:47:20 +08:00
|
|
|
int foo();
|
|
|
|
|
2018-08-31 02:56:11 +08:00
|
|
|
static int baz1() { return 0; }
|
2018-03-15 23:47:20 +08:00
|
|
|
|
|
|
|
int baz2();
|
|
|
|
|
|
|
|
int baz4() { return 5; }
|
|
|
|
|
2018-05-01 22:09:46 +08:00
|
|
|
template <typename T>
|
|
|
|
T FA() {
|
2018-05-02 23:45:28 +08:00
|
|
|
TemplateClass<T> s;
|
|
|
|
return s.f_method();
|
2018-05-01 22:09:46 +08:00
|
|
|
}
|
|
|
|
|
2018-03-15 23:47:20 +08:00
|
|
|
#pragma omp declare target
|
2018-05-01 02:09:40 +08:00
|
|
|
struct S {
|
|
|
|
int a;
|
|
|
|
S(int a) : a(a) {}
|
|
|
|
};
|
|
|
|
|
2018-03-15 23:47:20 +08:00
|
|
|
int foo() { return 0; }
|
|
|
|
int b = 15;
|
|
|
|
int d;
|
2018-05-09 22:15:18 +08:00
|
|
|
S globals(d);
|
2018-07-28 01:37:32 +08:00
|
|
|
static S stat(d);
|
2018-03-15 23:47:20 +08:00
|
|
|
#pragma omp end declare target
|
|
|
|
int c;
|
|
|
|
|
|
|
|
int bar() { return 1 + foo() + bar() + baz1() + baz2(); }
|
|
|
|
|
|
|
|
int maini1() {
|
|
|
|
int a;
|
2018-08-16 03:45:12 +08:00
|
|
|
static long aa = 32 + bbb + ccc + fff + ggg;
|
2022-03-25 07:32:05 +08:00
|
|
|
// CHECK-DAG: define weak_odr void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](i32* noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %{{.*}}, i64 {{.*}}, i64 {{.*}})
|
2018-03-15 23:47:20 +08:00
|
|
|
#pragma omp target map(tofrom \
|
2018-04-17 04:34:41 +08:00
|
|
|
: a, b)
|
2018-03-15 23:47:20 +08:00
|
|
|
{
|
2018-05-01 02:09:40 +08:00
|
|
|
S s(a);
|
2018-03-15 23:47:20 +08:00
|
|
|
static long aaa = 23;
|
2018-05-01 22:09:46 +08:00
|
|
|
a = foo() + bar() + b + c + d + aa + aaa + FA<int>();
|
2018-03-15 23:47:20 +08:00
|
|
|
}
|
|
|
|
return baz4();
|
|
|
|
}
|
|
|
|
|
2018-05-01 22:09:46 +08:00
|
|
|
int baz3() { return 2 + baz2(); }
|
2018-03-15 23:47:20 +08:00
|
|
|
int baz2() {
|
2022-03-25 07:32:05 +08:00
|
|
|
// CHECK-DAG: define weak_odr void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](i64 {{.*}})
|
2018-05-16 23:08:32 +08:00
|
|
|
#pragma omp target parallel
|
2018-03-15 23:47:20 +08:00
|
|
|
++c;
|
|
|
|
return 2 + baz3();
|
|
|
|
}
|
|
|
|
|
2018-08-21 02:03:40 +08:00
|
|
|
extern int create() throw();
|
|
|
|
|
|
|
|
static __typeof(create) __t_create __attribute__((__weakref__("__create")));
|
|
|
|
|
|
|
|
int baz5() {
|
|
|
|
bool a;
|
2022-03-25 07:32:05 +08:00
|
|
|
// CHECK-DAG: define weak_odr void @__omp_offloading_{{.*}}baz5{{.*}}_l[[@LINE+1]](i64 {{.*}})
|
2018-08-21 02:03:40 +08:00
|
|
|
#pragma omp target
|
|
|
|
a = __extension__(void *) & __t_create != 0;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2018-09-07 01:56:28 +08:00
|
|
|
template <typename T>
|
|
|
|
struct Base {
|
|
|
|
virtual ~Base() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
template class Base<int>;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct Bake {
|
|
|
|
virtual ~Bake() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
template class Bake<int>;
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
2018-09-21 22:55:26 +08:00
|
|
|
struct BaseNonT {
|
|
|
|
virtual ~BaseNonT() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
struct BakeNonT {
|
|
|
|
virtual ~BakeNonT() {}
|
|
|
|
};
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
2018-11-08 03:11:14 +08:00
|
|
|
template <typename T>
|
|
|
|
struct B {
|
|
|
|
virtual void virtual_foo();
|
|
|
|
};
|
|
|
|
|
|
|
|
void new_bar() { new B<int>(); }
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void B<T>::virtual_foo() {
|
|
|
|
#pragma omp target
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
2018-11-29 03:00:07 +08:00
|
|
|
struct A {
|
|
|
|
virtual void emitted() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct C : public A {
|
|
|
|
virtual void emitted();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void C<T>::emitted() {
|
|
|
|
#pragma omp target
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
A *X = new C<int>();
|
|
|
|
X->emitted();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}virtual_foo{{.*}}_l[[@LINE-25]]()
|
|
|
|
// CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}emitted{{.*}}_l[[@LINE-11]]()
|
|
|
|
|
2020-01-16 06:37:12 +08:00
|
|
|
template <typename T>
|
|
|
|
struct TTT {
|
|
|
|
virtual void emitted() {
|
|
|
|
#pragma omp target
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}emitted{{.*}}_l[[@LINE-5]]()
|
|
|
|
|
2022-01-16 17:53:11 +08:00
|
|
|
// CHECK-DAG: declare extern_weak noundef signext i32 @__create()
|
2018-08-21 02:03:40 +08:00
|
|
|
|
2018-11-08 03:11:14 +08:00
|
|
|
// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
|
2018-08-30 04:41:37 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: !{i32 1, !"aaa", i32 0, i32 {{[0-9]+}}}
|
|
|
|
// CHECK-DAG: !{i32 1, !"ccc", i32 0, i32 {{[0-9]+}}}
|
2018-11-08 03:11:14 +08:00
|
|
|
// CHECK-DAG: !{{{.+}}virtual_foo
|
2018-08-30 04:41:37 +08:00
|
|
|
|
2019-08-24 00:11:14 +08:00
|
|
|
#ifdef OMP5
|
|
|
|
void host_fun() {}
|
|
|
|
#pragma omp declare target to(host_fun) device_type(host)
|
|
|
|
void device_fun() {}
|
|
|
|
#pragma omp declare target to(device_fun) device_type(nohost)
|
|
|
|
// HOST5-NOT: define {{.*}}void {{.*}}device_fun{{.*}}
|
|
|
|
// HOST5: define {{.*}}void {{.*}}host_fun{{.*}}
|
|
|
|
// HOST5-NOT: define {{.*}}void {{.*}}device_fun{{.*}}
|
|
|
|
|
|
|
|
// DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
|
|
|
|
// DEV5: define {{.*}}void {{.*}}device_fun{{.*}}
|
|
|
|
// DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
|
|
|
|
#endif // OMP5
|
|
|
|
|
2021-04-21 15:27:32 +08:00
|
|
|
struct PAIR {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
PAIR pair __attribute__((address_space(3), loader_uninitialized));
|
|
|
|
#pragma omp end declare target
|
|
|
|
|
2018-03-15 23:47:20 +08:00
|
|
|
#endif // HEADER
|
2020-01-16 06:37:12 +08:00
|
|
|
|
|
|
|
#ifdef LOAD
|
|
|
|
#pragma omp declare target
|
|
|
|
void new_bar1() {
|
|
|
|
TTT<int> *X = new TTT<int>();
|
|
|
|
X->emitted();
|
|
|
|
}
|
|
|
|
#pragma omp end declare target
|
2022-01-15 06:21:46 +08:00
|
|
|
|
|
|
|
struct SS {
|
|
|
|
#pragma omp declare target
|
|
|
|
static int SSS;
|
|
|
|
#pragma omp end declare target
|
|
|
|
};
|
|
|
|
int SS::SSS = 1;
|
2022-01-21 01:06:47 +08:00
|
|
|
|
2020-01-16 06:37:12 +08:00
|
|
|
#endif
|