1 // RUN: %clang_cc1 -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
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DLOAD | FileCheck %s
3 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -DLOAD | FileCheck %s
6 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix HOST5
7 // 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 -DOMP5
8 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck %s --check-prefix DEV5
10 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix KMPC-ONLY
12 // RUN: %clang_cc1 -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
13 // 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 -DOMP5
14 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck %s --check-prefix SIMD-ONLY
16 // 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 -fopenmp-version=45
17 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=45 | FileCheck %s --check-prefix SIMD-ONLY
18 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fvisibility=protected -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=45
19 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-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
21 // expected-no-diagnostics
23 // SIMD-ONLY-NOT: {{__kmpc|__tgt}}
24 // KMPC-ONLY-NOT: __tgt
26 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
28 // CHECK-NOT: @{{hhh|ggg|fff|eee}} =
29 // CHECK-DAG: @flag = protected global i8 undef,
30 // CHECK-DAG: @dx = {{protected | }}global i32 0,
31 // CHECK-DAG: @dy = {{protected | }}global i32 0,
32 // CHECK-DAG: @bbb = {{protected | }}global i32 0,
33 // CHECK-DAG: weak constant %struct.__tgt_offload_entry { ptr @bbb,
34 // CHECK-DAG: @ccc = external global i32,
35 // CHECK-DAG: @ddd = {{protected | }}global i32 0,
36 // CHECK-DAG: @hhh_decl_tgt_ref_ptr = weak global ptr null
37 // CHECK-DAG: @ggg_decl_tgt_ref_ptr = weak global ptr null
38 // CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global ptr null
39 // CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global ptr null
40 // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
41 // CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef
42 // CHECK-DAG: @_ZN2SS3SSSE ={{ protected | }}global i32 1,
43 // CHECK-DAG: @b ={{ protected | }}global i32 15,
44 // CHECK-DAG: @d ={{ protected | }}global i32 0,
45 // CHECK-DAG: @c = external global i32,
46 // CHECK-DAG: @globals ={{ protected | }}global %struct.S zeroinitializer,
47 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
48 // CHECK-DAG: [[STAT_REF:@.+]] = internal constant ptr [[STAT]]
49 // CHECK-DAG: @out_decl_target ={{ protected | }}global i32 0,
50 // CHECK-DAG: @llvm.compiler.used = appending global [1 x ptr] [ptr [[STAT_REF]]],
52 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
53 // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(ptr {{[^,]*}} %{{.*}})
54 // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(ptr {{[^,]*}} %{{.*}})
55 // CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}_globals_l[[@LINE+89]]_ctor()
62 #pragma omp declare target to(dx)
65 #pragma omp begin declare target
68 #pragma omp end declare target
70 #pragma omp declare target
71 bool flag
[[clang::loader_uninitialized
]];
73 #pragma omp end declare target
74 #pragma omp declare target
76 #pragma omp end declare target
78 #pragma omp declare target
83 #pragma omp end declare target
85 #pragma omp declare target
87 #pragma omp end declare target
93 #pragma omp declare target link(eee, fff, ggg, hhh)
95 int out_decl_target
= 0;
97 #pragma omp declare target(out_decl_target)
100 #pragma omp declare target
103 (void)[&] { (void)out_decl_target
; };
105 #pragma clang __debug captured
107 (void)out_decl_target
;
111 #pragma omp end declare target
113 template <typename T
>
114 class TemplateClass
{
118 T
f_method() const { return a
; }
123 static int baz1() { return 0; }
127 int baz4() { return 5; }
129 template <typename T
>
135 #pragma omp declare target
141 int foo() { return 0; }
146 #pragma omp end declare target
149 int bar() { return 1 + foo() + bar() + baz1() + baz2(); }
153 static long aa
= 32 + bbb
+ ccc
+ fff
+ ggg
;
154 // CHECK-DAG: define weak_odr protected void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](ptr {{.*}}, ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %{{.*}}, i64 {{.*}}, i64 {{.*}})
155 #pragma omp target map(tofrom \
159 static long aaa
= 23;
160 a
= foo() + bar() + b
+ c
+ d
+ aa
+ aaa
+ FA
<int>();
165 int baz3() { return 2 + baz2(); }
167 // CHECK-DAG: define weak_odr protected void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](ptr {{.*}}, i64 {{.*}})
168 #pragma omp target parallel
173 extern int create() throw();
175 static __typeof(create
) __t_create
__attribute__((__weakref__("__create")));
179 // CHECK-DAG: define weak_odr protected void @__omp_offloading_{{.*}}baz5{{.*}}_l[[@LINE+1]](ptr {{.*}}, i64 {{.*}})
181 a
= __extension__(void *) & __t_create
!= 0;
185 template <typename T
>
190 template class Base
<int>;
192 template <typename T
>
197 #pragma omp declare target
198 template class Bake
<int>;
199 #pragma omp end declare target
202 virtual ~BaseNonT() {}
205 #pragma omp declare target
207 virtual ~BakeNonT() {}
209 #pragma omp end declare target
211 template <typename T
>
213 virtual void virtual_foo();
216 void new_bar() { new B
<int>(); }
218 template <typename T
>
219 void B
<T
>::virtual_foo() {
225 virtual void emitted() {}
228 template <typename T
>
229 struct C
: public A
{
230 virtual void emitted();
233 template <typename T
>
234 void C
<T
>::emitted() {
245 // CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}virtual_foo{{.*}}_l[[@LINE-25]](ptr {{.*}})
246 // CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}emitted{{.*}}_l[[@LINE-11]](ptr {{.*}})
248 template <typename T
>
250 virtual void emitted() {
256 // CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}emitted{{.*}}_l[[@LINE-5]](ptr {{.*}})
258 // CHECK-DAG: declare extern_weak noundef signext i32 @__create()
260 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
262 // CHECK-DAG: !{{{.+}}virtual_foo
266 #pragma omp declare target to(host_fun) device_type(host)
268 #pragma omp declare target to(device_fun) device_type(nohost)
269 // HOST5-NOT: define {{.*}}void {{.*}}device_fun{{.*}}
270 // HOST5: define {{.*}}void {{.*}}host_fun{{.*}}
271 // HOST5-NOT: define {{.*}}void {{.*}}device_fun{{.*}}
273 // DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
274 // DEV5: define {{.*}}void {{.*}}device_fun{{.*}}
275 // DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
283 #pragma omp declare target
284 PAIR pair
__attribute__((address_space(3), loader_uninitialized
));
285 #pragma omp end declare target
290 #pragma omp declare target
292 TTT
<int> *X
= new TTT
<int>();
295 #pragma omp end declare target
298 #pragma omp declare target
300 #pragma omp end declare target