[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / declare_variant_mixed_codegen.cpp
blobd0c3373302f78a9dddca5244793a8f9d40ede1f5
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|10|13|15|19|22|23|24}}'
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=45 %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|10|13|15|19|22|23|24}}'
5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|10|13|15|19|22|23|24}}'
6 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|10|13|15|19|22|23|24}}'
9 // expected-no-diagnostics
11 // CHECK-DAG: ret i32 2
12 // CHECK-DAG: ret i32 3
13 // CHECK-DAG: ret i32 4
14 // CHECK-DAG: ret i32 5
15 // CHECK-DAG: ret i32 9
16 // CHECK-DAG: ret i32 11
17 // CHECK-DAG: ret i32 12
18 // CHECK-DAG: ret i32 14
19 // CHECK-DAG: ret i32 16
20 // CHECK-DAG: ret i32 17
21 // CHECK-DAG: ret i32 18
22 // CHECK-DAG: ret i32 19
23 // CHECK-DAG: ret i32 20
24 // CHECK-DAG: ret i32 21
25 // CHECK-DAG: ret i32 25
26 // CHECK-DAG: ret i32 26
27 // CHECK-DAG: ret i32 27
28 // CHECK-DAG: ret i32 28
29 // CHECK-DAG: ret i32 29
30 // CHECK-DAG: ret i32 30
31 // CHECK-DAG: ret i32 31
33 #ifndef HEADER
34 #define HEADER
36 int foo() { return 2; }
38 #pragma omp declare variant(foo) match(implementation = {vendor(llvm)}, device={kind(cpu)})
39 int bar() { return 3; }
41 int bazzz();
42 #pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)}, device={kind(host)})
43 int baz() { return 4; }
45 int test();
46 #pragma omp declare variant(test) match(implementation = {vendor(llvm)}, device={kind(cpu)})
47 int call() { return 5; }
49 static int stat_unused_no_emit() { return 6; }
50 static int stat_unused_();
51 #pragma omp declare variant(stat_unused_) match(implementation = {vendor(llvm)}, device={kind(cpu)})
52 #pragma omp declare variant(stat_unused_no_emit) match(implementation = {vendor(unknown)}, device = {kind(gpu)})
53 static int stat_unused() { return 7; }
55 static int stat_used_();
56 #pragma omp declare variant(stat_used_) match(implementation = {vendor(llvm)}, device={kind(host)})
57 static int stat_used() { return 8; }
59 int main() { return bar() + baz() + call() + stat_used(); }
61 int test() { return 9; }
62 static int stat_unused_() { return 10; }
63 static int stat_used_() { return 11; }
65 struct SpecialFuncs {
66 void vd() {}
67 SpecialFuncs();
68 ~SpecialFuncs();
70 int method_() { return 12; }
71 #pragma omp declare variant(SpecialFuncs::method_) \
72 match(implementation = {vendor(llvm)}, device={kind(cpu)})
73 int method() { return 13; }
74 #pragma omp declare variant(SpecialFuncs::method_) \
75 match(implementation = {vendor(llvm)}, device={kind(host)})
76 int Method();
77 } s;
79 int SpecialFuncs::Method() { return 14; }
81 struct SpecSpecialFuncs {
82 void vd() {}
83 SpecSpecialFuncs();
84 ~SpecSpecialFuncs();
86 int method_();
87 #pragma omp declare variant(SpecSpecialFuncs::method_) \
88 match(implementation = {vendor(llvm)}, device={kind(cpu)})
89 int method() { return 15; }
90 #pragma omp declare variant(SpecSpecialFuncs::method_) \
91 match(implementation = {vendor(llvm)}, device={kind(host)})
92 int Method();
93 } s1;
95 int SpecSpecialFuncs::method_() { return 16; }
96 int SpecSpecialFuncs::Method() { return 17; }
98 void xxx() {
99 (void)s.method();
100 (void)s1.method();
103 int prio() { return 18; }
104 int prio1() { return 19; }
106 #pragma omp declare variant(prio1) match(implementation = {vendor(score(2): llvm)}, device={kind(cpu,host)})
107 #pragma omp declare variant(prio) match(implementation = {vendor(score(1): llvm)}, device={kind(cpu)})
108 int prio_() { return 20; }
110 static int prio2() { return 21; }
111 static int prio3() { return 22; }
112 static int prio4() { return 23; }
114 #pragma omp declare variant(prio4) match(implementation = {vendor(score(5): llvm)})
115 #pragma omp declare variant(prio2) match(implementation = {vendor(score(8): llvm)}, device={kind(cpu,host)})
116 #pragma omp declare variant(prio3) match(implementation = {vendor(score(7): llvm)}, device={kind(cpu)})
117 static int prio1_() { return 24; }
119 int int_fn() { return prio1_(); }
121 int fn_linkage_variant() { return 25; }
122 extern "C" {
123 #pragma omp declare variant(fn_linkage_variant) match(implementation = {vendor(llvm)}, device={kind(cpu)})
124 int fn_linkage() { return 26; }
127 extern "C" int fn_linkage_variant1() { return 27; }
128 #pragma omp declare variant(fn_linkage_variant1) match(implementation = {vendor(llvm)}, device={kind(host)})
129 int fn_linkage1() { return 28; }
131 int fn_variant2() { return 29; }
132 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm, ibm)}, device={kind(cpu)})
133 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm)}, device={kind(cpu,gpu)})
134 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm)}, device={kind(nohost)})
135 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm)}, device={kind(cpu,nohost)})
136 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm)}, device={kind(gpu)})
137 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm)}, device={kind(fpga)})
138 int fn2() { return 30; }
140 #pragma omp declare variant(stat_unused_no_emit) match(implementation = {vendor(unknown)}, device = {kind(gpu)})
141 template <typename T>
142 static T stat_unused_T() { return 31; }
144 int bazzzzzzzz() {
145 return stat_unused_T<int>();
148 #endif // HEADER