1 // expected-no-diagnostics 2 #ifndef HEADER 3 #define HEADER 4 5 #ifdef CK1 6 ///==========================================================================/// 7 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK1 8 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 9 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 10 11 // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 12 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 13 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 14 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 15 16 // CK1-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 17 // CK1-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 18 // CK1-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 19 20 // CK1-LABEL: foo 21 void foo() { extern void mayThrow(); mayThrow(); } 22 23 void parallel_master() { 24 #pragma omp parallel master 25 foo(); 26 } 27 28 // CK1-LABEL: define{{.*}} void @{{.+}}parallel_master{{.+}} 29 // CK1: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*)) 30 31 // CK1: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GTID:%.+]], i32* noalias [[BTID:%.+]]) 32 // CK1-NOT: __kmpc_global_thread_num 33 // CK1: call i32 @__kmpc_master({{.+}}) 34 // CK1: invoke void {{.*}}foo{{.*}}() 35 // CK1-NOT: __kmpc_global_thread_num 36 // CK1: call void @__kmpc_end_master({{.+}}) 37 // CK1: call void @__clang_call_terminate 38 // CK1: unreachable 39 40 #endif 41 42 #ifdef CK2 43 ///==========================================================================/// 44 // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK2 45 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 46 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 47 48 // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 49 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 50 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 51 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 52 53 // CK2-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 54 // CK2-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 55 // CK2-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 56 57 void parallel_master_private() { 58 int a; 59 #pragma omp parallel master private(a) 60 a++; 61 } 62 63 // CK2-LABEL: define{{.*}} void @{{.+}}parallel_master_private{{.+}} 64 // CK2: [[A_PRIV:%.+]] = alloca i32 65 // CK2: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*)) 66 67 // CK2: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GTID:%.+]], i32* noalias [[BTID:%.+]]) 68 // CK2-NOT: __kmpc_global_thread_num 69 // CK2: call i32 @__kmpc_master({{.+}}) 70 // CK2: [[A_VAL:%.+]] = load i32, i32* [[A_PRIV]] 71 // CK2: [[INC:%.+]] = add nsw i32 [[A_VAL]] 72 // CK2: store i32 [[INC]], i32* [[A_PRIV]] 73 // CK2-NOT: __kmpc_global_thread_num 74 // CK2: call void @__kmpc_end_master({{.+}}) 75 // CK2: ret void 76 77 #endif 78 79 #ifdef CK3 80 ///==========================================================================/// 81 // RUN: %clang_cc1 -DCK3 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK3 82 // RUN: %clang_cc1 -DCK3 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 83 // RUN: %clang_cc1 -DCK3 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK3 84 85 // RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 86 // RUN: %clang_cc1 -DCK3 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 87 // RUN: %clang_cc1 -DCK3 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 88 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 89 90 // CK3-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 91 // CK3-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 92 93 void parallel_master_private() { 94 int a; 95 #pragma omp parallel master default(shared) 96 a++; 97 } 98 99 // CK3-LABEL: define{{.*}} void @{{.+}}parallel_master{{.+}} 100 // CK3: [[A_VAL:%.+]] = alloca i32 101 // CK3: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void 102 103 // CK3: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GTID:%.+]], i32* noalias [[BTID:%.+]], i32* nonnull align 4 dereferenceable(4) [[A_VAL]]) 104 // CK3: [[GTID_ADDR:%.+]] = alloca i32* 105 // CK3: [[BTID_ADDR:%.+]] = alloca i32* 106 // CK3: [[A_ADDR:%.+]] = alloca i32* 107 // CK3: store i32* [[GTID]], i32** [[GTID_ADDR]] 108 // CK3: store i32* [[BTID]], i32** [[BTID_ADDR]] 109 // CK3: store i32* [[A_VAL]], i32** [[A_ADDR]] 110 // CK3: [[ZERO:%.+]] = load i32*, i32** [[A_ADDR]] 111 // CK3-NOT: __kmpc_global_thread_num 112 // CK3: call i32 @__kmpc_master({{.+}}) 113 // CK3: [[FIVE:%.+]] = load i32, i32* [[ZERO]] 114 // CK3: [[INC:%.+]] = add nsw i32 [[FIVE]] 115 // CK3: store i32 [[INC]], i32* [[ZERO]] 116 // CK3-NOT: __kmpc_global_thread_num 117 // CK3: call void @__kmpc_end_master({{.+}}) 118 119 #endif 120 121 #ifdef CK31 122 ///==========================================================================/// 123 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK31 124 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 125 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK31 126 127 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 128 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 129 // RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 130 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 131 132 // CK31-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 133 // CK31-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 134 135 void parallel_master_default_firstprivate() { 136 int a; 137 #pragma omp parallel master default(firstprivate) 138 a++; 139 } 140 141 // CK31-LABEL: define{{.*}} void @{{.+}}parallel_master{{.+}} 142 // CK31: [[A_VAL:%.+]] = alloca i32{{.+}} 143 // CK31: [[A_CASTED:%.+]] = alloca i64 144 // CK31: [[ZERO_VAL:%.+]] = load i32, i32* [[A_VAL]] 145 // CK31: [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32* 146 // CK31: store i32 [[ZERO_VAL]], i32* [[CONV]] 147 // CK31: [[ONE_VAL:%.+]] = load i64, i64* [[A_CASTED]] 148 // CK31: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i64 [[ONE_VAL]]) 149 // CK31: ret void 150 151 // CK31: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 152 // CK31: [[BOUND_TID_ADDR:%.+]] = alloca i32* 153 // CK31: [[A_ADDR:%.+]] = alloca i64{{.+}} 154 // CK31: store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]]{{.+}} 155 // CK31: store i32* [[BOUND_TID:%.+]], i32** [[BOUND_TID_ADDR]] 156 // CK31: store i64 [[A_VAL]], i64* [[A_ADDR]] 157 // CK31: [[CONV]] = bitcast i64* [[A_ADDR]] 158 // CK31: [[ZERO_VAL]] = load i32*, i32** [[GLOBAL_TID_ADDR]] 159 // CK31: [[ONE_VAL]] = load i32, i32* [[ZERO_VAL]] 160 // CK31: [[TWO_VAL:%.+]] = call i32 @__kmpc_master(%struct.ident_t* @{{.*}}, i32 [[ONE_VAL]]) 161 // CK31: [[THREE:%.+]] = icmp ne i32 [[TWO_VAL]], 0 162 // CK31: br i1 %3, label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]] 163 164 // CK31: [[FOUR:%.+]] = load i32, i32* [[CONV:%.+]] 165 // CK31: [[INC:%.+]] = add nsw i32 [[FOUR]] 166 // CK31: store i32 [[INC]], i32* [[CONV]] 167 // CK31: call void @__kmpc_end_master(%struct.ident_t* @{{.*}}, i32 [[ONE_VAL]]) 168 // CK31: br label [[OMP_IF_END]] 169 170 // CK31: ret void 171 172 #endif 173 174 #ifdef CK32 175 ///==========================================================================/// 176 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK32 177 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 178 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK32 179 180 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 181 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 182 // RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 183 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 184 185 // CK32-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 186 // CK32-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 187 188 struct St { 189 int a, b; 190 static int y; 191 St() : a(0), b(0) {} 192 ~St() {} 193 }; 194 int St::y = 0; 195 196 void parallel_master_default_firstprivate() { 197 St a = St(); 198 static int y = 0; 199 #pragma omp parallel master default(firstprivate) 200 { 201 a.a += 1; 202 a.b += 1; 203 y++; 204 a.y++; 205 } 206 } 207 208 // CK32-LABEL: define {{.+}} @{{.+}}parallel_master_default_firstprivate{{.+}} 209 // CK32: [[A_VAL:%.+]] = alloca %struct.St{{.+}} 210 // CK32: [[Y_CASTED:%.+]] = alloca i64 211 // CK32: call void @[[CTOR:.+]](%struct.St* {{[^,]*}} [[A_VAL]]) 212 // CK32: [[ZERO:%.+]] = load i32, i32* @{{.+}}parallel_master_default_firstprivate{{.+}} 213 // CK32: [[CONV:%.+]] = bitcast i64* [[Y_CASTED]] to i32* 214 // CK32: store i32 [[ZERO]], i32* [[CONV]] 215 // CK32: [[ONE:%.+]] = load i64, i64* [[Y_CASTED]] 216 // CK32: call void {{.+}}@{{.+}} %struct.St* [[A_VAL]], i64 [[ONE]]) 217 // CK32: call void [[DTOR:@.+]](%struct.St* {{[^,]*}} [[A_VAL]]) 218 219 // CK32: [[THIS_ADDR:%.+]] = alloca %struct.St* 220 // CK32: store %struct.St* [[THIS:%.+]], %struct.St** [[THIS_ADDR]] 221 // CK32: [[THIS_ONE:%.+]] = load %struct.St*, %struct.St** [[THIS_ADDR]] 222 // CK32: call void [[CTOR_2:.+]](%struct.St* {{[^,]*}} [[THIS_ONE]]) 223 // CK32: ret void 224 225 // CK32: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 226 // CK32: [[BOUND_TID_ADDR:%.+]] = alloca i32* 227 // CK32: [[A_ADDR:%.+]] = alloca %struct.St 228 // CK32: [[Y_ADDR:%.+]] = alloca i64 229 // CK32: store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]] 230 // CK32: store i32* %.bound_tid., i32** [[BOUND_TID_ADDR]] 231 // CK32: store %struct.St* [[A_VAL]], %struct.St** [[A_ADDR]]{{.+}} 232 // CK32: store i64 [[Y:%.+]], i64* [[Y_ADDR]] 233 // CK32: [[ONE:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]] 234 // CK32: [[TWO:%.+]] = load i32, i32* [[ONE]] 235 // CK32: [[THREE:%.+]] = call i32 @{{.+}} i32 [[TWO]]) 236 // CK32: [[FOUR:%.+]] = icmp ne i32 [[THREE]], 0 237 // CK32: br i1 [[FOUR]], label [[IF_THEN:%.+]], label [[IF_END:%.+]] 238 239 // CK32: [[A_1:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 0 240 // CK32: [[FIVE:%.+]] = load i32, i32* [[A_1]] 241 // CK32: [[ADD:%.+]] = add nsw i32 [[FIVE]], 1 242 // CK32: store i32 [[ADD]], i32* [[A_1]] 243 // CK32: [[B:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 1 244 // CK32: [[SIX:%.+]] = load i32, i32* [[B]] 245 // CK32: [[ADD_2:%.+]] = add nsw i32 [[SIX]], 1 246 // CK32: store i32 [[ADD_2]], i32* [[B]] 247 // CK32: [[SEVEN:%.+]] = load i32, i32* [[CONV]] 248 // CK32: [[INC:%.+]] = add nsw i32 [[SEVEN]], 1 249 // CK32: store i32 [[INC]], i32* [[CONV]] 250 // CK32: [[EIGHT:%.+]] = load i32, i32* [[FUNC:@.+]] 251 // CK32: [[INC_3:%.+]] = add nsw i32 [[EIGHT]], 1 252 // CK32: store i32 [[INC_3]], i32* @{{.+}} 253 // CK32: call void @{{.+}} i32 [[TWO]]) 254 // CK32: br label [[IF_END]] 255 256 // CK32: [[DTOR]](%struct.St* {{[^,]*}} [[THIS]]) 257 // CK32: [[THIS_ADDR]] = alloca %struct.St* 258 // CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]] 259 // CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]] 260 // CK32: call void @_ZN2StD2Ev(%struct.St* {{[^,]*}} [[THIS_ONE]]) 261 262 // CK32: [[THIS_ADDR]] = alloca %struct.St* 263 // CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]] 264 // CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]] 265 // CK32: [[A_VAL]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 0 266 // CK32: store i32 0, i32* [[A_VAL]] 267 // CK32: [[B_VAL:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 1 268 // CK32: store i32 0, i32* [[B_VAL]] 269 // CK32: ret void 270 271 // CK32: [[THIS_ADDR:%.+]] = alloca %struct.St* 272 // CK32: store %struct.St* %this, %struct.St** [[THIS_ADDR]] 273 // CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]] 274 275 #endif 276 277 #ifdef CK4 278 ///==========================================================================/// 279 // RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK4 280 // RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 281 // RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK4 282 283 // RUN: %clang_cc1 -DCK4 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 284 // RUN: %clang_cc1 -DCK4 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 285 // RUN: %clang_cc1 -DCK4 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 286 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 287 288 // CK4-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 289 // CK4-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 290 // CK4-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 291 292 void parallel_master_firstprivate() { 293 int a; 294 #pragma omp parallel master firstprivate(a) 295 a++; 296 } 297 298 // CK4-LABEL: define{{.*}} void @{{.+}}parallel_master_firstprivate{{.+}} 299 // CK4: [[A_VAL:%.+]] = alloca i32 300 // CK4: [[A_CASTED:%.+]] = alloca i64 301 // CK4: [[ZERO:%.+]] = load i32, i32* [[A_VAL]] 302 // CK4: [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32* 303 // CK4: store i32 [[ZERO]], i32* [[CONV]] 304 // CK4: [[ONE:%.+]] = load i64, i64* [[A_CASTED]] 305 // CK4: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 [[ONE]]) 306 307 // CK4: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i64 [[A_VAL]]) 308 // CK4: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 309 // CK4: [[BOUND_TID_ADDR:%.+]] = alloca i32* 310 // CK4: [[A_ADDR:%.+]] = alloca i64 311 // CK4: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]] 312 // CK4: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]] 313 // CK4: store i64 [[A_VAL]], i64* [[A_ADDR]] 314 // CK4: [[CONV]] = bitcast i64* [[A_ADDR]] to i32* 315 // CK4-NOT: __kmpc_global_thread_num 316 // CK4: call i32 @__kmpc_master({{.+}}) 317 // CK4: [[FOUR:%.+]] = load i32, i32* [[CONV]] 318 // CK4: [[INC:%.+]] = add nsw i32 [[FOUR]] 319 // CK4: store i32 [[INC]], i32* [[CONV]] 320 // CK4-NOT: __kmpc_global_thread_num 321 // CK4: call void @__kmpc_end_master({{.+}}) 322 323 #endif 324 325 #ifdef CK5 326 ///==========================================================================/// 327 // RUN: %clang_cc1 -DCK5 -verify -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK5 328 // RUN: %clang_cc1 -DCK5 -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 329 // RUN: %clang_cc1 -DCK5 -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK5 330 331 // RUN: %clang_cc1 -DCK5 -verify -fopenmp-simd -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 332 // RUN: %clang_cc1 -DCK5 -fopenmp-simd -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 333 // RUN: %clang_cc1 -DCK5 -fopenmp-simd -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 334 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 335 336 // RUN: %clang_cc1 -DCK5 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=TLS-CHECK 337 // RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s 338 // RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TLS-CHECK 339 340 // RUN: %clang_cc1 -DCK5 -verify -fopenmp-simd -x c++ -triple x86_64-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s 341 // RUN: %clang_cc1 -DCK5 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s 342 // RUN: %clang_cc1 -DCK5 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s 343 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} 344 345 // CK5-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 346 // CK5-DAG: [[A:@.+]] = {{.+}} i32 0 347 // CK5-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 348 // CK5-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 349 // CK5-DAG: [[A_CACHE:@.+]] = common{{.*}} global i8** null 350 // CK5-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 66, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 351 // TLS-CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 352 // TLS-CHECK-DAG: [[A:@.+]] ={{.*}} thread_local global i32 0 353 // TLS-CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 354 // TLS-CHECK-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 66, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 355 // TLS-CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 356 357 int a; 358 #pragma omp threadprivate(a) 359 360 void parallel_master_copyin() { 361 #pragma omp parallel master copyin(a) 362 a++; 363 } 364 365 // CK5-LABEL: define{{.*}} void @{{.+}}parallel_master_copyin{{.+}} 366 // CK5: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_1]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*)) 367 // CK5: ret void 368 // TLS-CHECK-LABEL: define{{.*}} void @{{.+}}parallel_master_copyin{{.+}} 369 // TLS-CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*) 370 // TLS-CHECK: ret void 371 372 // CK5: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]]) 373 // CK5: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 374 // CK5: [[BOUND_TID_ADDR:%.+]] = alloca i32* 375 // CK5: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]] 376 // CK5: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]] 377 // CK5: [[ZERO:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]] 378 // CK5: [[ONE:%.+]] = load i32, i32* [[ZERO]] 379 // CK5: [[TWO:%.+]] = call i8* @__kmpc_threadprivate_cached(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]], i8* bitcast (i32* [[A]] to i8*), i64 4, i8*** [[A_CACHE]]) 380 // CK5: [[THREE:%.+]] = bitcast i8* [[TWO]] to i32* 381 // CK5: [[FOUR:%.+]] = ptrtoint i32* [[THREE]] to i64 382 // CK5: [[FIVE:%.+]] = icmp ne i64 ptrtoint (i32* [[A]] to i64), [[FOUR]] 383 // CK5: br i1 [[FIVE]], label [[COPYIN_NOT_MASTER:%.+]], label [[COPYIN_NOT_MASTER_END:%.+]] 384 // TLS-CHECK: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i32* {{.+}} [[A_VAR:%.+]]) 385 // TLS-CHECK: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 386 // TLS-CHECK: [[BOUND_TID_ADDR:%.+]] = alloca i32* 387 // TLS-CHECK: [[A_ADDR:%.+]] = alloca i32* 388 // TLS-CHECK: store i32* [[A_VAR]], i32** [[A_ADDR]] 389 // TLS-CHECK: [[ZERO:%.+]] = load i32*, i32** [[A_ADDR]] 390 // TLS-CHECK: [[ONE:%.+]] = ptrtoint i32* [[ZERO]] to i64 391 // TLS-CHECK: [[TWO:%.+]] = icmp ne i64 [[ONE]], ptrtoint (i32* [[A]] to i64) 392 // TLS-CHECK: br i1 [[TWO]], label [[COPYIN_NOT_MASTER:%.+]], label [[COPYIN_NOT_MASTER_END:%.+]] 393 394 // CK5-DAG: [[COPYIN_NOT_MASTER]] 395 // CK5-DAG: [[SIX:%.+]] = load i32, i32* [[A]] 396 // TLS-CHECK-DAG: [[COPYIN_NOT_MASTER]] 397 // TLS-CHECK-DAG: [[THREE:%.+]] = load i32, i32* [[ZERO]] 398 // TLS-CHECK-DAG: store i32 [[THREE]], i32* [[A]] 399 400 // CK5-DAG: [[COPYIN_NOT_MASTER_END]] 401 // CK5-DAG: call void @__kmpc_barrier(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE]]) 402 // CK5-DAG: [[SEVEN:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]]) 403 // CK5-DAG: [[EIGHT:%.+]] = icmp ne i32 [[SEVEN]], 0 404 // CK5-DAG: br i1 %8, label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]] 405 // TLS-CHECK-DAG: [[FOUR:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR:%.+]] 406 // TLS-CHECK-DAG: [[FIVE:%.+]] = load i32, i32* [[FOUR]] 407 // TLS-CHECK-DAG: call void @__kmpc_barrier(%struct.ident_t* [[DEF_LOC_1]], i32 [[FIVE]]) 408 // TLS-CHECK-DAG: [[SIX:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]] 409 // TLS-CHECK-DAG: [[SEVEN:%.+]] = load i32, i32* [[SIX]] 410 // TLS-CHECK-DAG: [[EIGHT:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[SEVEN]]) 411 // TLS-CHECK-DAG: [[NINE:%.+]] = icmp ne i32 [[EIGHT]], 0 412 // TLS-CHECK-DAG: br i1 [[NINE]], label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]] 413 414 // CK5-DAG: [[OMP_IF_THEN]] 415 // CK5-DAG: [[NINE:%.+]] = call i8* @__kmpc_threadprivate_cached(%struct.ident_t* [[DEF_LOC_1]], i32 %1, i8* bitcast (i32* [[A]] to i8*), i64 4, i8*** [[A_CACHE]]) 416 // CK5-DAG: [[TEN:%.+]] = bitcast i8* [[NINE]] to i32* 417 // CK5-DAG: [[ELEVEN:%.+]] = load i32, i32* [[TEN]] 418 // CK5-DAG: [[INC:%.+]] = add nsw i32 [[ELEVEN]], 1 419 // CK5-DAG: store i32 [[INC]], i32* [[TEN]] 420 // CK5-DAG: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]]) 421 // CK5-DAG: [[OMP_IF_END]] 422 // CK5-DAG: ret void 423 424 // TLS-CHECK-DAG: [[OMP_IF_THEN]] 425 // TLS-CHECK-DAG: [[TEN:%.+]] = load i32, i32* [[A]] 426 // TLC-CHECK-DAG: [[INC:%.+]] = add nsw i32 [[TEN]], 1 427 // TLC-CHECK-DAG: store i32 [[INC]], i32* [[TEN]] 428 // TLS-CHECK-DAG: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[SEVEN]]) 429 // TLS-CHECK-DAG: [[OMP_IF_END]] 430 // TLS-CHECK-DAG: ret void 431 432 #endif 433 #ifdef CK6 434 ///==========================================================================/// 435 // RUN: %clang_cc1 -DCK6 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CK6 436 // RUN: %clang_cc1 -DCK6 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s 437 // RUN: %clang_cc1 -DCK6 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=CK6 438 439 // RUN: %clang_cc1 -DCK6 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s 440 // RUN: %clang_cc1 -DCK6 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s 441 // RUN: %clang_cc1 -DCK6 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s 442 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} 443 444 // CK6-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 445 // CK6-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 446 // CK6-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 447 // CK6-DAG: [[GOMP:@.+]] = common{{.*}} global [8 x i32] zeroinitializer 448 // CK6-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 18, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 449 450 void parallel_master_reduction() { 451 int g; 452 #pragma omp parallel master reduction(+:g) 453 g = 1; 454 } 455 456 // CK6-LABEL: define{{.*}} void @{{.+}}parallel_master_reduction{{.+}} 457 // CK6: [[G_VAR:%.+]] = alloca i32 458 // CK6: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_1]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i32* [[G_VAR]]) 459 // CK6: ret void 460 461 // CK6: define internal void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i32* {{.+}} [[G_VAR]]) 462 // CK6: [[GTID_ADDR:%.+]] = alloca i32* 463 // CK6: [[BTID_ADDR:%.+]] = alloca i32* 464 // CK6: [[G_ADDR:%.+]] = alloca i32* 465 // CK6: [[G_1:%.+]] = alloca i32 466 // CK6: [[RED_LIST:%.+]] = alloca [1 x i8*] 467 // CK6: [[ZERO:%.+]] = load i32*, i32** [[G_ADDR]] 468 // CK6: [[ONE:%.+]] = load i32*, i32** [[GTID_ADDR]] 469 // CK6: [[TWO:%.+]] = load i32, i32* [[ONE]] 470 // CK6: [[THREE:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[TWO]]) 471 // CK6: [[FOUR:%.+]] = icmp ne i32 [[THREE]] 472 473 // CK6: store i32 1, i32* [[G_1]] 474 // CK6: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[TWO]]) 475 476 // CK6: [[FIVE:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0 477 // CK6: [[SEVEN:%.+]] = bitcast [1 x i8*]* [[RED_LIST]] to i8* 478 // CK6: [[EIGHT:%.+]] = call i32 @__kmpc_reduce_nowait(%struct.ident_t* [[DEF_LOC_2]], i32 [[TWO]], i32 1, i64 8, i8* [[SEVEN]], void (i8*, i8*)* [[RED_FUNC:@.+]], [8 x i32]* [[RED_VAR:@.+]]) 479 480 // switch 481 // CK6: switch i32 [[EIGHT]], label [[RED_DEFAULT:%.+]] [ 482 // CK6: i32 1, label [[CASE1:%.+]] 483 // CK6: i32 2, label [[CASE2:%.+]] 484 485 // case 1: 486 // CK6: [[NINE:%.+]] = load i32, i32* %0, align 4 487 // CK6: [[TEN:%.+]] = load i32, i32* [[G_1]] 488 // CK6: [[ADD:%.+]] = add nsw i32 [[NINE]], [[TEN]] 489 // CK6: store i32 [[ADD]], i32* [[ZERO]] 490 // CK6: call void @__kmpc_end_reduce_nowait(%struct.ident_t* [[DEF_LOC_2]], i32 [[TWO]], [8 x i32]* [[GOMP]]) 491 // CK6: br label [[RED_DEFAULT]] 492 493 // case 2: 494 // CK6: [[ELEVEN:%.+]] = load i32, i32* [[G_1]] 495 // CK6: [[TWELVE:%.+]] = atomicrmw add i32* [[ZERO]], i32 [[ELEVEN]] monotonic, align 4 496 497 // CK6: define internal void [[RED_FUNC]](i8* [[ZERO]], i8* [[ONE]]) 498 // CK6: ret void 499 #endif 500 #ifdef CK7 501 ///==========================================================================/// 502 // RUN: %clang_cc1 -DCK7 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK7 503 // RUN: %clang_cc1 -DCK7 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 504 // RUN: %clang_cc1 -DCK7 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK7 505 506 // RUN: %clang_cc1 -DCK7 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 507 // RUN: %clang_cc1 -DCK7 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 508 // RUN: %clang_cc1 -DCK7 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 509 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 510 511 // CK7-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 512 // CK7-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 513 // CK7-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 514 515 void parallel_master_if() { 516 #pragma omp parallel master if (parallel: false) 517 parallel_master_if(); 518 } 519 520 // CK7-LABEL: parallel_master_if 521 // CK7: [[ZERO:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* [[DEF_LOC_1]]) 522 // CK7: call void @__kmpc_serialized_parallel(%struct.ident_t* [[DEF_LOC_1]], i32 [[ZERO]]) 523 // CK7: call void [[OUTLINED:@.+]](i32* [[THREAD_TEMP:%.+]], i32* [[BND_ADDR:%.+]]) 524 // CK7: call void @__kmpc_end_serialized_parallel(%struct.ident_t* [[DEF_LOC_1]], i32 [[ZERO]]) 525 // CK7: ret void 526 527 // CK7: define internal void @.omp_outlined.(i32* noalias [[GTID:%.+]], i32* noalias [[BTID:%.+]]) 528 // CK7: [[EXECUTE:%.+]] = call i32 @__kmpc_master(%struct.ident_t* @1, i32 %1) 529 // CK7: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 %1) 530 531 #endif 532 #ifdef CK8 533 ///==========================================================================/// 534 // RUN: %clang_cc1 -DCK8 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK8 535 // RUN: %clang_cc1 -DCK8 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 536 // RUN: %clang_cc1 -DCK8 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK8 537 538 // RUN: %clang_cc1 -DCK8 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 539 // RUN: %clang_cc1 -DCK8 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 540 // RUN: %clang_cc1 -DCK8 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 541 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 542 543 typedef __INTPTR_TYPE__ intptr_t; 544 545 // CK8-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } 546 // CK8-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 547 // CK8-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 548 549 void foo(); 550 551 struct S { 552 intptr_t a, b, c; 553 S(intptr_t a) : a(a) {} 554 operator char() { return a; } 555 ~S() {} 556 }; 557 558 template <typename T> 559 T tmain() { 560 #pragma omp parallel master proc_bind(master) 561 foo(); 562 return T(); 563 } 564 565 int main() { 566 #pragma omp parallel master proc_bind(spread) 567 foo(); 568 #pragma omp parallel master proc_bind(close) 569 foo(); 570 return tmain<int>(); 571 } 572 573 // CK8-LABEL: @main 574 // CK8: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]]) 575 // CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 4) 576 // CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 577 // CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 3) 578 // CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 579 580 // CK8-LABEL: @{{.+}}tmain 581 // CK8: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]]) 582 // CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 2) 583 // CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 584 // CK8: ret i32 0 585 // CK8-NEXT: } 586 587 // CK8: call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE:%.+]]) 588 // CK8: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE]]) 589 590 #endif 591 #ifdef CK9 592 ///==========================================================================/// 593 // RUN: %clang_cc1 -DCK9 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK9 594 // RUN: %clang_cc1 -DCK9 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 595 // RUN: %clang_cc1 -DCK9 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK9 596 597 // RUN: %clang_cc1 -DCK9 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 598 // RUN: %clang_cc1 -DCK9 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 599 // RUN: %clang_cc1 -DCK9 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 600 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 601 // CK9-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } 602 // CK9-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 603 // CK9-DAG: [[DEF_LOC:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 604 typedef void **omp_allocator_handle_t; 605 extern const omp_allocator_handle_t omp_null_allocator; 606 extern const omp_allocator_handle_t omp_default_mem_alloc; 607 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 608 extern const omp_allocator_handle_t omp_const_mem_alloc; 609 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 610 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 611 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 612 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 613 extern const omp_allocator_handle_t omp_thread_mem_alloc; 614 615 void parallel_master_allocate() { 616 int a; 617 omp_allocator_handle_t myalloc = nullptr; 618 #pragma omp parallel master firstprivate(a) allocate(myalloc:a) 619 a++; 620 } 621 622 // CK9-LABEL: define{{.*}} void @{{.+}}parallel_master_allocate{{.+}} 623 // CK9: [[A_VAL:%.+]] = alloca i32, 624 // CK9: [[A_CASTED:%.+]] = alloca i64 625 // CK9: [[ZERO:%.+]] = load i32, i32* [[A_VAL]] 626 // CK9: [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32* 627 // CK9: store i32 [[ZERO]], i32* [[CONV]] 628 // CK9: [[ONE:%.+]] = load i64, i64* [[A_CASTED]] 629 // CK9: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i8***)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 [[ONE]], i8*** %{{.+}}) 630 631 // CK9: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i64 [[A_VAL]], i8*** {{.*}}) 632 // CK9: [[GLOBAL_TID_ADDR:%.+]] = alloca i32* 633 // CK9: [[BOUND_TID_ADDR:%.+]] = alloca i32* 634 // CK9: [[A_ADDR:%.+]] = alloca i64, 635 // CK9: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]] 636 // CK9: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]] 637 // CK9: store i64 [[A_VAL]], i64* [[A_ADDR]] 638 // CK9: [[CONV]] = bitcast i64* [[A_ADDR]] to i32* 639 // CK9: [[A_FP_VOID_ADDR:%.+]] = call i8* @__kmpc_alloc(i32 %{{.+}}, i64 4, i8* %{{.+}}) 640 // CK9: [[A_FP_ADDR:%.+]] = bitcast i8* [[A_FP_VOID_ADDR]] to i32* 641 // CK9: [[A:%.+]] = load i32, i32* [[CONV]], 642 // CK9: store i32 [[A]], i32* [[A_FP_ADDR]], 643 // CK9-NOT: __kmpc_global_thread_num 644 // CK9: call i32 @__kmpc_master({{.+}}) 645 // CK9: [[FOUR:%.+]] = load i32, i32* [[A_FP_ADDR]] 646 // CK9: [[INC:%.+]] = add nsw i32 [[FOUR]] 647 // CK9: store i32 [[INC]], i32* [[A_FP_ADDR]] 648 // CK9-NOT: __kmpc_global_thread_num 649 // CK9: call void @__kmpc_end_master({{.+}}) 650 #endif 651 #endif 652