1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -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:%.+]] = type { i32, i32, i32, i32, i8* }
10*0a6a1f1dSLionel Sambuc // CHECK-DAG: [[EXPLICIT_BARRIER_LOC:@.+]] = {{.+}} [[IDENT_T]] { i32 0, i32 34, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]+}} x i8]* @{{.+}}, i32 0, i32 0) }
11*0a6a1f1dSLionel Sambuc // CHECK-DAG: [[LOC:@.+]] = {{.+}} [[IDENT_T]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]+}} x i8]* @{{.+}}, i32 0, i32 0) }
12*0a6a1f1dSLionel Sambuc
foo()13*0a6a1f1dSLionel Sambuc void foo() {}
14*0a6a1f1dSLionel Sambuc
15*0a6a1f1dSLionel Sambuc template <class T>
tmain(T argc)16*0a6a1f1dSLionel Sambuc T tmain(T argc) {
17*0a6a1f1dSLionel Sambuc static T a;
18*0a6a1f1dSLionel Sambuc #pragma omp barrier
19*0a6a1f1dSLionel Sambuc return a + argc;
20*0a6a1f1dSLionel Sambuc }
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @main
main(int argc,char ** argv)23*0a6a1f1dSLionel Sambuc int main(int argc, char **argv) {
24*0a6a1f1dSLionel Sambuc static int a;
25*0a6a1f1dSLionel Sambuc #pragma omp barrier
26*0a6a1f1dSLionel Sambuc // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* [[LOC]])
27*0a6a1f1dSLionel Sambuc // CHECK: call i32 @__kmpc_cancel_barrier([[IDENT_T]]* [[EXPLICIT_BARRIER_LOC]], i32 [[GTID]])
28*0a6a1f1dSLionel Sambuc // CHECK: call {{.+}} [[TMAIN_INT:@.+]](i{{[0-9][0-9]}}
29*0a6a1f1dSLionel Sambuc // CHECK: call {{.+}} [[TMAIN_CHAR:@.+]](i{{[0-9]}}
30*0a6a1f1dSLionel Sambuc return tmain(argc) + tmain(argv[0][0]) + a;
31*0a6a1f1dSLionel Sambuc }
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel Sambuc // CHECK: define {{.+}} [[TMAIN_INT]](
34*0a6a1f1dSLionel Sambuc // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* [[LOC]])
35*0a6a1f1dSLionel Sambuc // CHECK: call i32 @__kmpc_cancel_barrier([[IDENT_T]]* [[EXPLICIT_BARRIER_LOC]], i32 [[GTID]])
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc // CHECK: define {{.+}} [[TMAIN_CHAR]](
38*0a6a1f1dSLionel Sambuc // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* [[LOC]])
39*0a6a1f1dSLionel Sambuc // CHECK: call i32 @__kmpc_cancel_barrier([[IDENT_T]]* [[EXPLICIT_BARRIER_LOC]], i32 [[GTID]])
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc #endif
42