brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.3 KiB · 9620613 Raw
140 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL2// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s3// RUN: %clang_cc1 -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,NORMAL4// RUN: %clang_cc1 -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_DEBUG5// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER6// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s7// RUN: %clang_cc1 -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,IRBUILDER8 9// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s10// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s11// RUN: %clang_cc1 -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 %s12// RUN: %clang_cc1 -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 %s13// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}14// expected-no-diagnostics15#ifndef HEADER16#define HEADER17 18// ALL:       [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }19// ALL:       [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer20// ALL:       [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer21// ALL:       [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer22 23// ALL:       define {{.*}}void [[FOO:@.+]]()24 25void foo() { extern void mayThrow(); mayThrow(); }26 27// ALL-LABEL: @main28// TERM_DEBUG-LABEL: @main29int main() {30  // ALL:       [[A_ADDR:%.+]] = alloca i831  char a;32 33// ALL:       			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])34// ALL:       			call {{.*}}void @__kmpc_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[UNNAMED_LOCK]])35// ALL-NEXT:  			store i8 2, ptr [[A_ADDR]]36// IRBUILDER-NEXT:		br label %[[AFTER:[^ ,]+]]37// IRBUILDER:			[[AFTER]]38// IRBUILDER-NEXT:		br label %[[OMP_REGION_FINALIZE:[^ ,]+]]39// IRBUILDER:			[[OMP_REGION_FINALIZE]]40// ALL-NEXT:  			call {{.*}}void @__kmpc_end_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[UNNAMED_LOCK]])41#pragma omp critical42  a = 2;43// IRBUILDER:       [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])44// ALL:       			call {{.*}}void @__kmpc_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[THE_NAME_LOCK]])45// IRBUILDER-NEXT:	call {{.*}}void [[FOO]]()46// NORMAL-NEXT:  		invoke {{.*}}void [[FOO]]()47// IRBUILDER-NEXT:		br label %[[AFTER:[^ ,]+]]48// IRBUILDER:			[[AFTER]]49// ALL:      				call {{.*}}void @__kmpc_end_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[THE_NAME_LOCK]])50#pragma omp critical(the_name)51  foo();52// IRBUILDER:   		[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])53// ALL: 	      		call {{.*}}void @__kmpc_critical_with_hint(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[THE_NAME_LOCK1]], i{{64|32}} 23)54// IRBUILDER-NEXT:	call {{.*}}void [[FOO]]()55// NORMAL-NEXT:		  invoke {{.*}}void [[FOO]]()56// IRBUILDER-NEXT:		br label %[[AFTER:[^ ,]+]]57// IRBUILDER:			[[AFTER]]58// ALL:		       		call {{.*}}void @__kmpc_end_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[THE_NAME_LOCK1]])59#pragma omp critical(the_name1) hint(23)60  foo();61  // IRBUILDER:   		[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])62  // ALL:       call {{.*}}void @__kmpc_critical(ptr [[DEFAULT_LOC]], i32 [[GTID]], ptr [[THE_NAME_LOCK]])63  // NORMAL:       br label64  // NORMAL-NOT:   call {{.*}}void @__kmpc_end_critical(65  // NORMAL:       br label66  // NORMAL-NOT:   call {{.*}}void @__kmpc_end_critical(67  // NORMAL:       br label68  if (a)69#pragma omp critical(the_name)70    while (1)71      ;72  // ALL:  call {{.*}}void [[FOO]]()73  foo();74  // ALL-NOT:   call void @__kmpc_critical75  // ALL-NOT:   call void @__kmpc_end_critical76  return a;77}78 79// ALL-LABEL:        lambda_critical80// TERM_DEBUG-LABEL: lambda_critical81void lambda_critical(int a, int b) {82  auto l = [=]() {83#pragma omp critical84    {85      // ALL: call void @__kmpc_critical(86      int c = a + b;87    }88  };89 90  l();91 92  auto l1 = [=]() {93#pragma omp parallel94#pragma omp critical95    {96      // ALL: call void @__kmpc_critical(97      int c = a + b;98    }99  };100 101  l1();102}103 104struct S {105  int a;106};107// ALL-LABEL: critical_ref108void critical_ref(S &s) {109  // ALL: [[S_ADDR:%.+]] = alloca ptr,110  // ALL: [[S_REF:%.+]] = load ptr, ptr [[S_ADDR]],111  // ALL: [[S_A_REF:%.+]] = getelementptr inbounds nuw %struct.S, ptr [[S_REF]], i32 0, i32 0112  ++s.a;113  // ALL: call void @__kmpc_critical(114#pragma omp critical115  // ALL: [[S_REF:%.+]] = load ptr, ptr [[S_ADDR]],116  // ALL: [[S_A_REF:%.+]] = getelementptr inbounds nuw %struct.S, ptr [[S_REF]], i32 0, i32 0117  ++s.a;118  // ALL: call void @__kmpc_end_critical(119}120 121// ALL-LABEL:      parallel_critical122// TERM_DEBUG-LABEL: parallel_critical123void parallel_critical() {124#pragma omp parallel125#pragma omp critical126  // TERM_DEBUG-NOT: __kmpc_global_thread_num127  // TERM_DEBUG:     call void @__kmpc_critical({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]]128  // TERM_DEBUG:     invoke void {{.*}}foo{{.*}}()129  // TERM_DEBUG:     unwind label %[[TERM_LPAD:.+]],130  // TERM_DEBUG-NOT: __kmpc_global_thread_num131  // TERM_DEBUG:     call void @__kmpc_end_critical({{.+}}), !dbg [[DBG_LOC_END:![0-9]+]]132  // TERM_DEBUG:     [[TERM_LPAD]]133  // TERM_DEBUG:     call void @__clang_call_terminate134  // TERM_DEBUG:     unreachable135  foo();136}137// TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-12]],138// TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-3]],139#endif140