1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4*0a6a1f1dSLionel Sambuc // expected-no-diagnostics
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc #ifndef HEADER
7*0a6a1f1dSLionel Sambuc #define HEADER
8*0a6a1f1dSLionel Sambuc
9*0a6a1f1dSLionel Sambuc // CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
10*0a6a1f1dSLionel Sambuc // CHECK: [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
11*0a6a1f1dSLionel Sambuc // CHECK: [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
12*0a6a1f1dSLionel Sambuc
13*0a6a1f1dSLionel Sambuc // CHECK: define void [[FOO:@.+]]()
14*0a6a1f1dSLionel Sambuc
foo()15*0a6a1f1dSLionel Sambuc void foo() {}
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @main
main()18*0a6a1f1dSLionel Sambuc int main() {
19*0a6a1f1dSLionel Sambuc // CHECK: [[A_ADDR:%.+]] = alloca i8
20*0a6a1f1dSLionel Sambuc char a;
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel Sambuc // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
23*0a6a1f1dSLionel Sambuc // CHECK: call void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
24*0a6a1f1dSLionel Sambuc // CHECK-NEXT: store i8 2, i8* [[A_ADDR]]
25*0a6a1f1dSLionel Sambuc // CHECK-NEXT: call void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
26*0a6a1f1dSLionel Sambuc #pragma omp critical
27*0a6a1f1dSLionel Sambuc a = 2;
28*0a6a1f1dSLionel Sambuc // CHECK: call void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
29*0a6a1f1dSLionel Sambuc // CHECK-NEXT: call void [[FOO]]()
30*0a6a1f1dSLionel Sambuc // CHECK-NEXT: call void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
31*0a6a1f1dSLionel Sambuc #pragma omp critical(the_name)
32*0a6a1f1dSLionel Sambuc foo();
33*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @__kmpc_critical
34*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @__kmpc_end_critical
35*0a6a1f1dSLionel Sambuc return a;
36*0a6a1f1dSLionel Sambuc }
37*0a6a1f1dSLionel Sambuc
38*0a6a1f1dSLionel Sambuc #endif
39