| 1 |
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s |
| 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 |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -DOMP60 -verify -fopenmp -fopenmp-version=60 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefixes=CHECK,OMP60 %s |
| 6 |
// RUN: %clang_cc1 -DOMP60 -fopenmp -fopenmp-version=60 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s |
| 7 |
// RUN: %clang_cc1 -DOMP60 -fopenmp -fopenmp-version=60 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefixes=CHECK,OMP60 %s |
| 8 |
|
| 9 |
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 10 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s |
| 11 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 12 |
|
| 13 |
// RUN: %clang_cc1 -DOMP60 -verify -fopenmp-simd -fopenmp-version=60 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 14 |
// RUN: %clang_cc1 -DOMP60 -fopenmp-simd -fopenmp-version=60 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s |
| 15 |
// RUN: %clang_cc1 -DOMP60 -fopenmp-simd -fopenmp-version=60 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 16 |
|
| 17 |
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}} |
| 18 |
// expected-no-diagnostics |
| 19 |
#ifndef HEADER |
| 20 |
#define HEADER |
| 21 |
|
| 22 |
typedef __INTPTR_TYPE__ intptr_t; |
| 23 |
|
| 24 |
// CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr } |
| 25 |
// CHECK-DAG: [[S_TY:%.+]] = type { [[INTPTR_T_TY:i[0-9]+]], [[INTPTR_T_TY]], [[INTPTR_T_TY]] } |
| 26 |
// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" |
| 27 |
// CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 22, ptr [[STR]] } |
| 28 |
|
| 29 |
void foo(); |
| 30 |
|
| 31 |
struct S { |
| 32 |
intptr_t a, b, c; |
| 33 |
S(intptr_t a) : a(a) {} |
| 34 |
operator char() { extern void mayThrow(); mayThrow(); return a; } |
| 35 |
~S() {} |
| 36 |
}; |
| 37 |
|
| 38 |
template <typename T, int C> |
| 39 |
int tmain() { |
| 40 |
#pragma omp parallel num_threads(C) |
| 41 |
foo(); |
| 42 |
#pragma omp parallel num_threads(T(23)) |
| 43 |
foo(); |
| 44 |
#ifdef OMP60 |
| 45 |
char str[] = "msg"; |
| 46 |
const char *str1 = "msg1"; |
| 47 |
#pragma omp parallel num_threads(strict: C) severity(fatal) message(str) |
| 48 |
foo(); |
| 49 |
#pragma omp parallel num_threads(strict: T(23)) severity(warning) message(str1) |
| 50 |
foo(); |
| 51 |
#endif |
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
int main() { |
| 56 |
S s(0); |
| 57 |
char a = s; |
| 58 |
#pragma omp parallel num_threads(2) |
| 59 |
foo(); |
| 60 |
#pragma omp parallel num_threads(a) |
| 61 |
foo(); |
| 62 |
#ifdef OMP60 |
| 63 |
char str[] = "msg"; |
| 64 |
const char *str1 = "msg1"; |
| 65 |
#pragma omp parallel num_threads(strict: 2) severity(fatal) message(str) |
| 66 |
foo(); |
| 67 |
#pragma omp parallel num_threads(strict: a) severity(warning) message(str1) |
| 68 |
foo(); |
| 69 |
#endif |
| 70 |
return a + tmain<char, 5>() + tmain<S, 1>(); |
| 71 |
} |
| 72 |
|
| 73 |
// CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main() |
| 74 |
// CHECK-DAG: [[S_ADDR:%.+]] = alloca [[S_TY]] |
| 75 |
// CHECK-DAG: [[A_ADDR:%.+]] = alloca i8 |
| 76 |
// CHECK-DAG: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]]) |
| 77 |
// CHECK-DAG: call {{.*}} [[S_TY_CONSTR:@.+]](ptr {{[^,]*}} [[S_ADDR]], [[INTPTR_T_TY]] noundef [[INTPTR_T_TY_ATTR:(signext )?]]0) |
| 78 |
// CHECK: [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP:@.+]](ptr {{[^,]*}} [[S_ADDR]]) |
| 79 |
// CHECK: store i8 [[S_CHAR_OP]], ptr [[A_ADDR]] |
| 80 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 2) |
| 81 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 82 |
// CHECK: [[A_VAL:%.+]] = load i8, ptr [[A_ADDR]] |
| 83 |
// CHECK: [[RES:%.+]] = sext i8 [[A_VAL]] to i32 |
| 84 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]]) |
| 85 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 86 |
// OMP60: [[ARRDECAY:%.+]] = getelementptr inbounds [4 x i8], ptr [[STR:%.+]], [[INTPTR_T_TY]] 0, [[INTPTR_T_TY]] 0 |
| 87 |
// OMP60: call void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 2, i32 2, ptr [[ARRDECAY]]) |
| 88 |
// OMP60: call void (ptr, i32, ptr, ...) @__kmpc_fork_call( |
| 89 |
// OMP60: [[A_VAL1:%.+]] = load i8, ptr [[A_ADDR]] |
| 90 |
// OMP60: [[RES1:%.+]] = sext i8 [[A_VAL1]] to i32 |
| 91 |
// OMP60: call void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES1]], i32 1, ptr [[STR2:%.+]]) |
| 92 |
// OMP60: call void (ptr, i32, ptr, ...) @__kmpc_fork_call( |
| 93 |
// CHECK: invoke{{.*}} [[INT_TY:i[0-9]+]] [[TMAIN_CHAR_5:@.+]]() |
| 94 |
// CHECK: invoke{{.*}} [[INT_TY]] [[TMAIN_S_1:@.+]]() |
| 95 |
// CHECK: call {{.*}} [[S_TY_DESTR:@.+]](ptr {{[^,]*}} [[S_ADDR]]) |
| 96 |
// CHECK: ret [[INT_TY]] |
| 97 |
// CHECK: } |
| 98 |
|
| 99 |
// CHECK: define{{.*}} [[INT_TY]] [[TMAIN_CHAR_5]]() |
| 100 |
// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]]) |
| 101 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 5) |
| 102 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 103 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 23) |
| 104 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 105 |
// OMP60: [[ARRDECAY:%.+]] = getelementptr inbounds [4 x i8], ptr [[STR:%.+]], [[INTPTR_T_TY]] 0, [[INTPTR_T_TY]] 0 |
| 106 |
// OMP60: call {{.*}}void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 5, i32 2, ptr [[ARRDECAY]]) |
| 107 |
// OMP60: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 108 |
// OMP60: call {{.*}}void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 23, i32 1, ptr [[STR1:%.+]]) |
| 109 |
// OMP60: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 110 |
// CHECK: ret [[INT_TY]] 0 |
| 111 |
// CHECK-NEXT: } |
| 112 |
|
| 113 |
// CHECK: define{{.*}} [[INT_TY]] [[TMAIN_S_1]]() |
| 114 |
// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]]) |
| 115 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 1) |
| 116 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 117 |
// CHECK: {{(invoke|call)}} {{.*}} [[S_TY_CONSTR]](ptr {{[^,]*}} [[S_TEMP:%.+]], [[INTPTR_T_TY]] noundef [[INTPTR_T_TY_ATTR]]23) |
| 118 |
// CHECK: [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP]](ptr {{[^,]*}} [[S_TEMP]]) |
| 119 |
// CHECK: [[RES:%.+]] = sext {{.*}}i8 [[S_CHAR_OP]] to i32 |
| 120 |
// CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]]) |
| 121 |
// CHECK: {{(invoke|call)}} {{.*}} [[S_TY_DESTR]](ptr {{[^,]*}} [[S_TEMP]]) |
| 122 |
// CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 123 |
// OMP60: [[ARRDECAY:%.+]] = getelementptr inbounds [4 x i8], ptr [[STR:%.+]], [[INTPTR_T_TY]] 0, [[INTPTR_T_TY]] 0 |
| 124 |
// OMP60: call {{.*}}void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 1, i32 2, ptr [[ARRDECAY]]) |
| 125 |
// OMP60: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 126 |
// OMP60: {{(invoke|call)}} {{.*}} [[S_TY_CONSTR]](ptr {{[^,]*}} [[S_TEMP:%.+]], [[INTPTR_T_TY]] noundef [[INTPTR_T_TY_ATTR]]23) |
| 127 |
// OMP60: [[S_CHAR_OP1:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP]](ptr {{[^,]*}} [[S_TEMP]]) |
| 128 |
// OMP60: [[RES1:%.+]] = sext {{.*}}i8 [[S_CHAR_OP1]] to i32 |
| 129 |
// OMP60: call {{.*}}void @__kmpc_push_num_threads_strict(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES1]], i32 1, ptr [[STR1:%.+]]) |
| 130 |
// OMP60: {{(invoke|call)}} {{.*}} [[S_TY_DESTR]](ptr {{[^,]*}} [[S_TEMP]]) |
| 131 |
// OMP60: call {{.*}}void {{.*}} @__kmpc_fork_call( |
| 132 |
// CHECK: ret [[INT_TY]] 0 |
| 133 |
// CHECK: } |
| 134 |
|
| 135 |
#endif |