1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DHOST | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DHOST 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=50 -DHOST | FileCheck %s 4 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DHOST | FileCheck %s 5 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple aarch64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DHOST 6 // RUN: %clang_cc1 -fopenmp -x c++ -triple aarch64-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=50 -DHOST | FileCheck %s 7 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DHOST | FileCheck %s 8 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple ppc64le-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DHOST 9 // RUN: %clang_cc1 -fopenmp -x c++ -triple ppc64le-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=50 -DHOST | FileCheck %s 10 11 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DCPU | FileCheck %s 12 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DCPU 13 // 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=50 -DCPU | FileCheck %s 14 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DCPU | FileCheck %s 15 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple aarch64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DCPU 16 // RUN: %clang_cc1 -fopenmp -x c++ -triple aarch64-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=50 -DCPU | FileCheck %s 17 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -DCPU | FileCheck %s 18 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple ppc64le-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s -DCPU 19 // RUN: %clang_cc1 -fopenmp -x c++ -triple ppc64le-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=50 -DCPU | FileCheck %s 20 21 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=x86_64-unknown-linux -emit-llvm-bc %s -o %t-host.bc -DCPU 22 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - -DCPU | FileCheck %s 23 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -emit-pch -o %t -DCPU 24 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -include-pch %t -o - -DCPU | FileCheck %s 25 26 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -fopenmp-targets=ppc64le-unknown-linux -emit-llvm-bc %s -o %t-host.bc -DCPU 27 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - -DCPU | FileCheck %s 28 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -emit-pch -o %t -DCPU 29 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -include-pch %t -o - -DCPU | FileCheck %s 30 31 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=x86_64-unknown-linux -emit-llvm-bc %s -o %t-host.bc -DNOHOST 32 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - -DNOHOST | FileCheck %s 33 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -emit-pch -o %t -DNOHOST 34 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -include-pch %t -o - -DNOHOST | FileCheck %s 35 36 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -fopenmp-targets=ppc64le-unknown-linux -emit-llvm-bc %s -o %t-host.bc -DNOHOST 37 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - -DNOHOST | FileCheck %s 38 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -emit-pch -o %t -DNOHOST 39 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -include-pch %t -o - -DNOHOST | FileCheck %s 40 41 // expected-no-diagnostics 42 43 // CHECK-NOT: alias 44 45 // CHECK-NOT: ret i32 {{1|4|81|84}} 46 // CHECK-DAG: declare {{.*}}i32 @_Z5bazzzv() 47 // CHECK-DAG: define {{.*}}i32 @_Z3bazv() 48 // CHECK-DAG: ret i32 2 49 // CHECK-DAG: ret i32 3 50 // CHECK-DAG: ret i32 5 51 // CHECK-DAG: ret i32 6 52 // CHECK-DAG: ret i32 7 53 // CHECK-DAG: ret i32 82 54 // CHECK-DAG: ret i32 83 55 // CHECK-DAG: ret i32 85 56 // CHECK-DAG: ret i32 86 57 // CHECK-DAG: ret i32 87 58 // CHECK-NOT: ret i32 {{4|81|84}} 59 60 #ifndef HEADER 61 #define HEADER 62 63 #pragma omp declare target 64 #ifdef HOST 65 #define SUBSET host 66 #define CORRECT host, cpu 67 #define WRONG host, nohost 68 #endif // HOST 69 #ifdef CPU 70 #define SUBSET cpu 71 #define CORRECT cpu, any 72 #define WRONG cpu, gpu 73 #endif // CPU 74 #ifdef NOHOST 75 #define SUBSET nohost 76 #define CORRECT nohost, cpu 77 #define WRONG nohost, host 78 #endif // NOHOST 79 80 int foo() { return 2; } 81 82 #pragma omp declare variant(foo) match(device = {kind(CORRECT)}) 83 int bar() { return 1; } 84 85 int bazzz(); 86 #pragma omp declare variant(bazzz) match(device = {kind(CORRECT)}) 87 int baz() { return 1; } 88 89 int test(); 90 #pragma omp declare variant(test) match(device = {kind(CORRECT)}) 91 int call() { return 1; } 92 93 static int stat_unused_(); 94 #pragma omp declare variant(stat_unused_) match(device = {kind(CORRECT)}) 95 static int stat_unused() { return 1; } 96 97 static int stat_used_(); 98 #pragma omp declare variant(stat_used_) match(device = {kind(CORRECT)}) 99 static int stat_used() { return 1; } 100 101 int main() { return bar() + baz() + call() + stat_used(); } 102 103 int test() { return 3; } 104 static int stat_unused_() { return 4; } 105 static int stat_used_() { return 5; } 106 107 struct SpecialFuncs { 108 void vd() {} 109 SpecialFuncs(); 110 ~SpecialFuncs(); 111 112 int method_() { return 6; } 113 #pragma omp declare variant(SpecialFuncs::method_) \ 114 match(device = {kind(CORRECT)}) 115 int method() { return 1; } 116 #pragma omp declare variant(SpecialFuncs::method_) \ 117 match(device = {kind(CORRECT)}) 118 int Method(); 119 } s; 120 121 int SpecialFuncs::Method() { return 1; } 122 123 struct SpecSpecialFuncs { 124 void vd() {} 125 SpecSpecialFuncs(); 126 ~SpecSpecialFuncs(); 127 128 int method_(); 129 #pragma omp declare variant(SpecSpecialFuncs::method_) \ 130 match(device = {kind(CORRECT)}) 131 int method() { return 1; } 132 #pragma omp declare variant(SpecSpecialFuncs::method_) \ 133 match(device = {kind(CORRECT)}) 134 int Method(); 135 } s1; 136 137 int SpecSpecialFuncs::method_() { return 7; } 138 int SpecSpecialFuncs::Method() { return 1; } 139 140 void xxx() { 141 (void)s.method(); 142 (void)s1.method(); 143 } 144 145 int prio() { return 81; } 146 int prio1() { return 82; } 147 148 #pragma omp declare variant(prio) match(device = {kind(SUBSET)}) 149 #pragma omp declare variant(prio1) match(device = {kind(CORRECT)}) 150 int prio_() { return 1; } 151 152 static int prio2() { return 83; } 153 static int prio3() { return 84; } 154 static int prio4() { return 84; } 155 156 #pragma omp declare variant(prio4) match(device = {kind(SUBSET)}) 157 #pragma omp declare variant(prio2) match(device = {kind(CORRECT)}) 158 #pragma omp declare variant(prio3) match(device = {kind(SUBSET)}) 159 static int prio1_() { return 1; } 160 161 int int_fn() { return prio1_(); } 162 163 int fn_linkage_variant() { return 85; } 164 extern "C" { 165 #pragma omp declare variant(fn_linkage_variant) match(device = {kind(CORRECT)}) 166 int fn_linkage() { return 1; } 167 } 168 169 extern "C" int fn_linkage_variant1() { return 86; } 170 #pragma omp declare variant(fn_linkage_variant1) match(device = {kind(CORRECT)}) 171 int fn_linkage1() { return 1; } 172 173 int fn_variant2() { return 1; } 174 #pragma omp declare variant(fn_variant2) match(device = {kind(WRONG)}) 175 int fn2() { return 87; } 176 177 #pragma omp end declare target 178 #endif // HEADER 179