Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / declare_variant_implementation_vendor_codegen.cpp
blobd4077ce35d813e68a360270189d94670bfcdd316
1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -fopenmp-version=45 | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|9|10|12|13|14|15|19|21|22|23|24}}'
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|9|10|12|13|14|15|19|21|22|23|24}}'
4 // expected-no-diagnostics
6 // CHECK-DAG: ret i32 2
7 // CHECK-DAG: ret i32 3
8 // CHECK-DAG: ret i32 4
9 // CHECK-DAG: ret i32 5
10 // CHECK-DAG: ret i32 11
11 // CHECK-DAG: ret i32 16
12 // CHECK-DAG: ret i32 17
13 // CHECK-DAG: ret i32 18
14 // CHECK-DAG: ret i32 19
15 // CHECK-DAG: ret i32 20
16 // CHECK-DAG: ret i32 25
17 // CHECK-DAG: ret i32 26
18 // CHECK-DAG: ret i32 27
19 // CHECK-DAG: ret i32 28
20 // CHECK-DAG: ret i32 29
22 #ifndef HEADER
23 #define HEADER
25 int foo() { return 2; }
27 #pragma omp declare variant(foo) match(implementation = {vendor(llvm)})
28 int bar() { return 3; }
30 int bazzz();
31 #pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)})
32 int baz() { return 4; }
34 int test();
35 #pragma omp declare variant(test) match(implementation = {vendor(llvm)})
36 int call() { return 5; }
38 static int stat_unused_();
39 #pragma omp declare variant(stat_unused_) match(implementation = {vendor(llvm)})
40 static int stat_unused() { return 6; }
42 static int stat_used_();
43 #pragma omp declare variant(stat_used_) match(implementation = {vendor(llvm)})
44 static int stat_used() { return 7; }
46 int main() { return bar() + baz() + call() + stat_used(); }
48 int test() { return 8; }
49 static int stat_unused_() { return 9; }
50 static int stat_used_() { return 10; }
52 struct SpecialFuncs {
53 void vd() {}
54 SpecialFuncs();
55 ~SpecialFuncs();
57 int method_() { return 11; }
58 #pragma omp declare variant(SpecialFuncs::method_) \
59 match(implementation = {vendor(llvm)})
60 int method() { return 12; }
61 #pragma omp declare variant(SpecialFuncs::method_) \
62 match(implementation = {vendor(llvm)})
63 int Method();
64 } s;
66 int SpecialFuncs::Method() { return 13; }
68 struct SpecSpecialFuncs {
69 void vd() {}
70 SpecSpecialFuncs();
71 ~SpecSpecialFuncs();
73 int method_();
74 #pragma omp declare variant(SpecSpecialFuncs::method_) \
75 match(implementation = {vendor(llvm)})
76 int method() { return 14; }
77 #pragma omp declare variant(SpecSpecialFuncs::method_) \
78 match(implementation = {vendor(llvm)})
79 int Method();
80 } s1;
82 int SpecSpecialFuncs::method_() { return 15; }
83 int SpecSpecialFuncs::Method() { return 16; }
85 void xxx() {
86 (void)s.method();
87 (void)s1.method();
90 int prio() { return 17; }
91 int prio1() { return 18; }
93 #pragma omp declare variant(prio) match(implementation = {vendor(llvm)})
94 #pragma omp declare variant(prio1) match(implementation = {vendor(score(1): llvm)})
95 int prio_() { return 19; }
97 static int prio2() { return 20; }
98 static int prio3() { return 21; }
99 static int prio4() { return 22; }
101 #pragma omp declare variant(prio4) match(implementation = {vendor(score(3): llvm)})
102 #pragma omp declare variant(prio2) match(implementation = {vendor(score(5): llvm)})
103 #pragma omp declare variant(prio3) match(implementation = {vendor(score(1): llvm)})
104 static int prio1_() { return 23; }
106 int int_fn() { return prio1_(); }
108 int fn_linkage_variant() { return 24; }
109 extern "C" {
110 #pragma omp declare variant(fn_linkage_variant) match(implementation = {vendor(llvm)})
111 int fn_linkage() { return 25; }
114 extern "C" int fn_linkage_variant1() { return 26; }
115 #pragma omp declare variant(fn_linkage_variant1) match(implementation = {vendor(llvm)})
116 int fn_linkage1() { return 27; }
118 int fn_variant2() { return 28; }
119 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm, ibm)})
120 int fn2() { return 29; }
122 #endif // HEADER