1 // RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL 2 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 3 // RUN: %clang_cc1 -no-opaque-pointers -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-prefixes=ALL,NORMAL 4 // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG 5 // RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER 6 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 7 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER 8 9 // RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 10 // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 11 // RUN: %clang_cc1 -no-opaque-pointers -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 12 // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s 13 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 14 // expected-no-diagnostics 15 #ifndef HEADER 16 #define HEADER 17 18 // ALL: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } 19 20 // ALL: define {{.*}}void [[FOO:@.+]]() 21 22 void foo() { extern void mayThrow(); mayThrow(); } 23 24 // ALL-LABEL: @main 25 // TERM_DEBUG-LABEL: @main 26 int main() { 27 // ALL: [[A_ADDR:%.+]] = alloca i8 28 char a; 29 30 // ALL: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) 31 // ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) 32 // ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 33 // ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] 34 // ALL: [[THEN]] 35 // ALL-NEXT: store i8 2, i8* [[A_ADDR]] 36 // IRBUILDER-NEXT: br label %[[AFTER:[^ ,]+]] 37 // IRBUILDER: [[AFTER]] 38 // ALL-NEXT: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) 39 // ALL-NEXT: br label {{%?}}[[EXIT]] 40 // ALL: [[EXIT]] 41 #pragma omp master 42 a = 2; 43 // IRBUILDER: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) 44 // ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) 45 // ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 46 // ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] 47 // ALL: [[THEN]] 48 // IRBUILDER-NEXT: call {{.*}}void [[FOO]]() 49 // NORMAL-NEXT: invoke {{.*}}void [[FOO]]() 50 // ALL: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) 51 // ALL-NEXT: br label {{%?}}[[EXIT]] 52 // ALL: [[EXIT]] 53 #pragma omp master 54 foo(); 55 // ALL-NOT: call i32 @__kmpc_master 56 // ALL-NOT: call void @__kmpc_end_master 57 return a; 58 } 59 60 // ALL-LABEL: lambda_master 61 // TERM_DEBUG-LABEL: lambda_master 62 void lambda_master(int a, int b) { 63 auto l = [=]() { 64 #pragma omp master 65 { 66 // ALL: call i32 @__kmpc_master( 67 int c = a + b; 68 } 69 }; 70 71 l(); 72 73 auto l1 = [=]() { 74 #pragma omp parallel 75 #pragma omp master 76 { 77 // ALL: call i32 @__kmpc_master( 78 int c = a + b; 79 } 80 }; 81 82 l1(); 83 84 auto l2 = [=]() { 85 #pragma omp parallel master 86 { 87 // ALL: call i32 @__kmpc_master( 88 int c = a + b; 89 } 90 }; 91 92 l2(); 93 } 94 95 // ALL-LABEL: parallel_master 96 // TERM_DEBUG-LABEL: parallel_master 97 void parallel_master() { 98 #pragma omp parallel 99 #pragma omp master 100 // TERM_DEBUG-NOT: __kmpc_global_thread_num 101 // TERM_DEBUG: call i32 @__kmpc_master({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]] 102 // TERM_DEBUG: invoke void {{.*}}foo{{.*}}() 103 // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], 104 // TERM_DEBUG-NOT: __kmpc_global_thread_num 105 // TERM_DEBUG: call void @__kmpc_end_master({{.+}}), !dbg [[DBG_LOC_END:![0-9]+]] 106 // TERM_DEBUG: [[TERM_LPAD]] 107 // TERM_DEBUG: call void @__clang_call_terminate 108 // TERM_DEBUG: unreachable 109 foo(); 110 } 111 // TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-12]], 112 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-3]], 113 114 #endif 115