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
5 // 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
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
7 // 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
8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
9 // expected-no-diagnostics
13 typedef __INTPTR_TYPE__
intptr_t;
15 // CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
16 // CHECK-DAG: [[S_TY:%.+]] = type { [[INTPTR_T_TY:i[0-9]+]], [[INTPTR_T_TY]], [[INTPTR_T_TY]] }
17 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
18 // CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 22, ptr [[STR]] }
24 S(intptr_t a
) : a(a
) {}
25 operator char() { extern void mayThrow(); mayThrow(); return a
; }
29 template <typename T
, int C
>
31 #pragma omp parallel num_threads(C)
33 #pragma omp parallel num_threads(T(23))
41 #pragma omp parallel num_threads(2)
43 #pragma omp parallel num_threads(a)
45 return a
+ tmain
<char, 5>() + tmain
<S
, 1>();
48 // CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
49 // CHECK-DAG: [[S_ADDR:%.+]] = alloca [[S_TY]]
50 // CHECK-DAG: [[A_ADDR:%.+]] = alloca i8
51 // CHECK-DAG: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]])
52 // CHECK-DAG: call {{.*}} [[S_TY_CONSTR:@.+]](ptr {{[^,]*}} [[S_ADDR]], [[INTPTR_T_TY]] noundef [[INTPTR_T_TY_ATTR:(signext )?]]0)
53 // CHECK: [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP:@.+]](ptr {{[^,]*}} [[S_ADDR]])
54 // CHECK: store i8 [[S_CHAR_OP]], ptr [[A_ADDR]]
55 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 2)
56 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
57 // CHECK: [[A_VAL:%.+]] = load i8, ptr [[A_ADDR]]
58 // CHECK: [[RES:%.+]] = sext i8 [[A_VAL]] to i32
59 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]])
60 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
61 // CHECK: invoke{{.*}} [[INT_TY:i[0-9]+]] [[TMAIN_CHAR_5:@.+]]()
62 // CHECK: invoke{{.*}} [[INT_TY]] [[TMAIN_S_1:@.+]]()
63 // CHECK: call {{.*}} [[S_TY_DESTR:@.+]](ptr {{[^,]*}} [[S_ADDR]])
64 // CHECK: ret [[INT_TY]]
67 // CHECK: define{{.*}} [[INT_TY]] [[TMAIN_CHAR_5]]()
68 // CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]])
69 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 5)
70 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
71 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 23)
72 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
73 // CHECK: ret [[INT_TY]] 0
76 // CHECK: define{{.*}} [[INT_TY]] [[TMAIN_S_1]]()
77 // CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEF_LOC_2]])
78 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 1)
79 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
80 // CHECK: {{(invoke|call)}} {{.*}} [[S_TY_CONSTR]](ptr {{[^,]*}} [[S_TEMP:%.+]], [[INTPTR_T_TY]] noundef [[INTPTR_T_TY_ATTR]]23)
81 // CHECK: [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP]](ptr {{[^,]*}} [[S_TEMP]])
82 // CHECK: [[RES:%.+]] = sext {{.*}}i8 [[S_CHAR_OP]] to i32
83 // CHECK: call {{.*}}void @__kmpc_push_num_threads(ptr [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]])
84 // CHECK: {{(invoke|call)}} {{.*}} [[S_TY_DESTR]](ptr {{[^,]*}} [[S_TEMP]])
85 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call(
86 // CHECK: ret [[INT_TY]] 0