14e8231b5SAlexey Bataev // 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 24e8231b5SAlexey Bataev // 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 34e8231b5SAlexey Bataev // 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 44e8231b5SAlexey Bataev // 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 54e8231b5SAlexey Bataev // 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 64e8231b5SAlexey Bataev // 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 74e8231b5SAlexey Bataev // 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 84e8231b5SAlexey Bataev // 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 94e8231b5SAlexey Bataev // 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 104e8231b5SAlexey Bataev 114e8231b5SAlexey Bataev // 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 124e8231b5SAlexey Bataev // 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 134e8231b5SAlexey Bataev // 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 144e8231b5SAlexey Bataev // 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 154e8231b5SAlexey Bataev // 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 164e8231b5SAlexey Bataev // 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 174e8231b5SAlexey Bataev // 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 184e8231b5SAlexey Bataev // 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 194e8231b5SAlexey Bataev // 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 204e8231b5SAlexey Bataev 214e8231b5SAlexey Bataev // 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 224e8231b5SAlexey Bataev // 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 234e8231b5SAlexey Bataev // 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 244e8231b5SAlexey Bataev // 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 254e8231b5SAlexey Bataev 264e8231b5SAlexey Bataev // 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 274e8231b5SAlexey Bataev // 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 284e8231b5SAlexey Bataev // 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 294e8231b5SAlexey Bataev // 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 304e8231b5SAlexey Bataev 314e8231b5SAlexey Bataev // 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 324e8231b5SAlexey Bataev // 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 334e8231b5SAlexey Bataev // 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 344e8231b5SAlexey Bataev // 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 354e8231b5SAlexey Bataev 364e8231b5SAlexey Bataev // 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 374e8231b5SAlexey Bataev // 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 384e8231b5SAlexey Bataev // 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 394e8231b5SAlexey Bataev // 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 404e8231b5SAlexey Bataev 414e8231b5SAlexey Bataev // expected-no-diagnostics 424e8231b5SAlexey Bataev 43*befb4be3SJohannes Doerfert // CHECK-NOT: alias 44*befb4be3SJohannes Doerfert 454e8231b5SAlexey Bataev // CHECK-NOT: ret i32 {{1|4|81|84}} 464e8231b5SAlexey Bataev // CHECK-DAG: declare {{.*}}i32 @_Z5bazzzv() 47*befb4be3SJohannes Doerfert // CHECK-DAG: define {{.*}}i32 @_Z3bazv() 484e8231b5SAlexey Bataev // CHECK-DAG: ret i32 2 494e8231b5SAlexey Bataev // CHECK-DAG: ret i32 3 504e8231b5SAlexey Bataev // CHECK-DAG: ret i32 5 514e8231b5SAlexey Bataev // CHECK-DAG: ret i32 6 524e8231b5SAlexey Bataev // CHECK-DAG: ret i32 7 534e8231b5SAlexey Bataev // CHECK-DAG: ret i32 82 544e8231b5SAlexey Bataev // CHECK-DAG: ret i32 83 554e8231b5SAlexey Bataev // CHECK-DAG: ret i32 85 564e8231b5SAlexey Bataev // CHECK-DAG: ret i32 86 574e8231b5SAlexey Bataev // CHECK-DAG: ret i32 87 58*befb4be3SJohannes Doerfert // CHECK-NOT: ret i32 {{4|81|84}} 594e8231b5SAlexey Bataev 604e8231b5SAlexey Bataev #ifndef HEADER 614e8231b5SAlexey Bataev #define HEADER 624e8231b5SAlexey Bataev 634e8231b5SAlexey Bataev #pragma omp declare target 644e8231b5SAlexey Bataev #ifdef HOST 651228d42dSJohannes Doerfert #define SUBSET host 661228d42dSJohannes Doerfert #define CORRECT host, cpu 674e8231b5SAlexey Bataev #define WRONG host, nohost 684e8231b5SAlexey Bataev #endif // HOST 694e8231b5SAlexey Bataev #ifdef CPU 701228d42dSJohannes Doerfert #define SUBSET cpu 711228d42dSJohannes Doerfert #define CORRECT cpu, any 724e8231b5SAlexey Bataev #define WRONG cpu, gpu 734e8231b5SAlexey Bataev #endif // CPU 744e8231b5SAlexey Bataev #ifdef NOHOST 751228d42dSJohannes Doerfert #define SUBSET nohost 761228d42dSJohannes Doerfert #define CORRECT nohost, cpu 774e8231b5SAlexey Bataev #define WRONG nohost, host 784e8231b5SAlexey Bataev #endif // NOHOST 794e8231b5SAlexey Bataev 804e8231b5SAlexey Bataev int foo() { return 2; } 814e8231b5SAlexey Bataev 824e8231b5SAlexey Bataev #pragma omp declare variant(foo) match(device = {kind(CORRECT)}) 834e8231b5SAlexey Bataev int bar() { return 1; } 844e8231b5SAlexey Bataev 854e8231b5SAlexey Bataev int bazzz(); 864e8231b5SAlexey Bataev #pragma omp declare variant(bazzz) match(device = {kind(CORRECT)}) 874e8231b5SAlexey Bataev int baz() { return 1; } 884e8231b5SAlexey Bataev 894e8231b5SAlexey Bataev int test(); 904e8231b5SAlexey Bataev #pragma omp declare variant(test) match(device = {kind(CORRECT)}) 914e8231b5SAlexey Bataev int call() { return 1; } 924e8231b5SAlexey Bataev 934e8231b5SAlexey Bataev static int stat_unused_(); 944e8231b5SAlexey Bataev #pragma omp declare variant(stat_unused_) match(device = {kind(CORRECT)}) 954e8231b5SAlexey Bataev static int stat_unused() { return 1; } 964e8231b5SAlexey Bataev 974e8231b5SAlexey Bataev static int stat_used_(); 984e8231b5SAlexey Bataev #pragma omp declare variant(stat_used_) match(device = {kind(CORRECT)}) 994e8231b5SAlexey Bataev static int stat_used() { return 1; } 1004e8231b5SAlexey Bataev 1014e8231b5SAlexey Bataev int main() { return bar() + baz() + call() + stat_used(); } 1024e8231b5SAlexey Bataev 1034e8231b5SAlexey Bataev int test() { return 3; } 1044e8231b5SAlexey Bataev static int stat_unused_() { return 4; } 1054e8231b5SAlexey Bataev static int stat_used_() { return 5; } 1064e8231b5SAlexey Bataev 1074e8231b5SAlexey Bataev struct SpecialFuncs { 1084e8231b5SAlexey Bataev void vd() {} 1094e8231b5SAlexey Bataev SpecialFuncs(); 1104e8231b5SAlexey Bataev ~SpecialFuncs(); 1114e8231b5SAlexey Bataev 1124e8231b5SAlexey Bataev int method_() { return 6; } 1134e8231b5SAlexey Bataev #pragma omp declare variant(SpecialFuncs::method_) \ 1144e8231b5SAlexey Bataev match(device = {kind(CORRECT)}) 1154e8231b5SAlexey Bataev int method() { return 1; } 1164e8231b5SAlexey Bataev #pragma omp declare variant(SpecialFuncs::method_) \ 1174e8231b5SAlexey Bataev match(device = {kind(CORRECT)}) 1184e8231b5SAlexey Bataev int Method(); 1194e8231b5SAlexey Bataev } s; 1204e8231b5SAlexey Bataev 1214e8231b5SAlexey Bataev int SpecialFuncs::Method() { return 1; } 1224e8231b5SAlexey Bataev 1234e8231b5SAlexey Bataev struct SpecSpecialFuncs { 1244e8231b5SAlexey Bataev void vd() {} 1254e8231b5SAlexey Bataev SpecSpecialFuncs(); 1264e8231b5SAlexey Bataev ~SpecSpecialFuncs(); 1274e8231b5SAlexey Bataev 1284e8231b5SAlexey Bataev int method_(); 1294e8231b5SAlexey Bataev #pragma omp declare variant(SpecSpecialFuncs::method_) \ 1304e8231b5SAlexey Bataev match(device = {kind(CORRECT)}) 1314e8231b5SAlexey Bataev int method() { return 1; } 1324e8231b5SAlexey Bataev #pragma omp declare variant(SpecSpecialFuncs::method_) \ 1334e8231b5SAlexey Bataev match(device = {kind(CORRECT)}) 1344e8231b5SAlexey Bataev int Method(); 1354e8231b5SAlexey Bataev } s1; 1364e8231b5SAlexey Bataev 1374e8231b5SAlexey Bataev int SpecSpecialFuncs::method_() { return 7; } 1384e8231b5SAlexey Bataev int SpecSpecialFuncs::Method() { return 1; } 1394e8231b5SAlexey Bataev 1404e8231b5SAlexey Bataev void xxx() { 1414e8231b5SAlexey Bataev (void)s.method(); 1424e8231b5SAlexey Bataev (void)s1.method(); 1434e8231b5SAlexey Bataev } 1444e8231b5SAlexey Bataev 1454e8231b5SAlexey Bataev int prio() { return 81; } 1464e8231b5SAlexey Bataev int prio1() { return 82; } 1474e8231b5SAlexey Bataev 1484e8231b5SAlexey Bataev #pragma omp declare variant(prio) match(device = {kind(SUBSET)}) 1494e8231b5SAlexey Bataev #pragma omp declare variant(prio1) match(device = {kind(CORRECT)}) 1504e8231b5SAlexey Bataev int prio_() { return 1; } 1514e8231b5SAlexey Bataev 1524e8231b5SAlexey Bataev static int prio2() { return 83; } 1534e8231b5SAlexey Bataev static int prio3() { return 84; } 1544e8231b5SAlexey Bataev static int prio4() { return 84; } 1554e8231b5SAlexey Bataev 1564e8231b5SAlexey Bataev #pragma omp declare variant(prio4) match(device = {kind(SUBSET)}) 1574e8231b5SAlexey Bataev #pragma omp declare variant(prio2) match(device = {kind(CORRECT)}) 1584e8231b5SAlexey Bataev #pragma omp declare variant(prio3) match(device = {kind(SUBSET)}) 1594e8231b5SAlexey Bataev static int prio1_() { return 1; } 1604e8231b5SAlexey Bataev 1614e8231b5SAlexey Bataev int int_fn() { return prio1_(); } 1624e8231b5SAlexey Bataev 1634e8231b5SAlexey Bataev int fn_linkage_variant() { return 85; } 1644e8231b5SAlexey Bataev extern "C" { 1654e8231b5SAlexey Bataev #pragma omp declare variant(fn_linkage_variant) match(device = {kind(CORRECT)}) 1664e8231b5SAlexey Bataev int fn_linkage() { return 1; } 1674e8231b5SAlexey Bataev } 1684e8231b5SAlexey Bataev 1694e8231b5SAlexey Bataev extern "C" int fn_linkage_variant1() { return 86; } 1704e8231b5SAlexey Bataev #pragma omp declare variant(fn_linkage_variant1) match(device = {kind(CORRECT)}) 1714e8231b5SAlexey Bataev int fn_linkage1() { return 1; } 1724e8231b5SAlexey Bataev 1734e8231b5SAlexey Bataev int fn_variant2() { return 1; } 1744e8231b5SAlexey Bataev #pragma omp declare variant(fn_variant2) match(device = {kind(WRONG)}) 1754e8231b5SAlexey Bataev int fn2() { return 87; } 1764e8231b5SAlexey Bataev 1774e8231b5SAlexey Bataev #pragma omp end declare target 1784e8231b5SAlexey Bataev #endif // HEADER 179