From 9ff848c5cd88947714f3d9bf03a3adbb84066736 Mon Sep 17 00:00:00 2001 From: cchen Date: Fri, 17 Sep 2021 16:44:09 -0500 Subject: [PATCH] Revert "[OpenMP] Use irbuilder as default for masked and master construct" This reverts commit 2908fc0d3f16f873b5019f1c62a24482c2b75e36. --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 96 +++++++++++++++++++++++------------- clang/test/OpenMP/masked_codegen.cpp | 93 +++++++++++++++++----------------- clang/test/OpenMP/master_codegen.cpp | 68 +++++++++++++------------ 3 files changed, 146 insertions(+), 111 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index b36fb70..68ab136 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4034,56 +4034,82 @@ static void emitMaster(CodeGenFunction &CGF, const OMPExecutableDirective &S) { } void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { - llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder(); - using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy; + if (CGM.getLangOpts().OpenMPIRBuilder) { + llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder(); + using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy; - const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt(); + const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt(); - auto FiniCB = [this](InsertPointTy IP) { - OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP); - }; + auto FiniCB = [this](InsertPointTy IP) { + OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP); + }; - auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP, - InsertPointTy CodeGenIP, - llvm::BasicBlock &FiniBB) { - OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB); - OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt, - CodeGenIP, FiniBB); - }; + auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP, + InsertPointTy CodeGenIP, + llvm::BasicBlock &FiniBB) { + OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB); + OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt, + CodeGenIP, FiniBB); + }; + LexicalScope Scope(*this, S.getSourceRange()); + EmitStopPoint(&S); + Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB)); + + return; + } LexicalScope Scope(*this, S.getSourceRange()); EmitStopPoint(&S); - Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB)); + emitMaster(*this, S); } -void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) { - llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder(); - using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy; - - const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt(); - const Expr *Filter = nullptr; +static void emitMasked(CodeGenFunction &CGF, const OMPExecutableDirective &S) { + auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) { + Action.Enter(CGF); + CGF.EmitStmt(S.getRawStmt()); + }; + Expr *Filter = nullptr; if (const auto *FilterClause = S.getSingleClause()) Filter = FilterClause->getThreadID(); - llvm::Value *FilterVal = Filter - ? EmitScalarExpr(Filter, CGM.Int32Ty) - : llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/0); + CGF.CGM.getOpenMPRuntime().emitMaskedRegion(CGF, CodeGen, S.getBeginLoc(), + Filter); +} - auto FiniCB = [this](InsertPointTy IP) { - OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP); - }; +void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) { + if (CGM.getLangOpts().OpenMPIRBuilder) { + llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder(); + using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy; - auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP, - InsertPointTy CodeGenIP, - llvm::BasicBlock &FiniBB) { - OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB); - OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MaskedRegionBodyStmt, - CodeGenIP, FiniBB); - }; + const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt(); + const Expr *Filter = nullptr; + if (const auto *FilterClause = S.getSingleClause()) + Filter = FilterClause->getThreadID(); + llvm::Value *FilterVal = Filter + ? EmitScalarExpr(Filter, CGM.Int32Ty) + : llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/0); + + auto FiniCB = [this](InsertPointTy IP) { + OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP); + }; + + auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP, + InsertPointTy CodeGenIP, + llvm::BasicBlock &FiniBB) { + OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB); + OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MaskedRegionBodyStmt, + CodeGenIP, FiniBB); + }; + LexicalScope Scope(*this, S.getSourceRange()); + EmitStopPoint(&S); + Builder.restoreIP( + OMPBuilder.createMasked(Builder, BodyGenCB, FiniCB, FilterVal)); + + return; + } LexicalScope Scope(*this, S.getSourceRange()); EmitStopPoint(&S); - Builder.restoreIP( - OMPBuilder.createMasked(Builder, BodyGenCB, FiniCB, FilterVal)); + emitMasked(*this, S); } void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) { diff --git a/clang/test/OpenMP/masked_codegen.cpp b/clang/test/OpenMP/masked_codegen.cpp index 90bf702..97cb037 100644 --- a/clang/test/OpenMP/masked_codegen.cpp +++ b/clang/test/OpenMP/masked_codegen.cpp @@ -1,7 +1,10 @@ -// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -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 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=51 -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -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 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s @@ -12,66 +15,68 @@ #ifndef HEADER #define HEADER -// CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } +// ALL: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } -// CHECK: define {{.*}}void [[FOO:@.+]]() +// ALL: define {{.*}}void [[FOO:@.+]]() void foo() { extern void mayThrow(); mayThrow(); } -// CHECK-LABEL: @main +// ALL-LABEL: @main // TERM_DEBUG-LABEL: @main int main() { - // CHECK: [[A_ADDR:%.+]] = alloca i8 + // ALL: [[A_ADDR:%.+]] = alloca i8 char a; -// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) -// CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 0) -// CHECK-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 -// CHECK-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] -// CHECK: [[THEN]] -// CHECK-NEXT: store i8 2, i8* [[A_ADDR]] -// CHECK-NEXT: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: br label {{%?}}[[EXIT]] -// CHECK: [[EXIT]] +// ALL: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) +// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 0) +// ALL-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 +// ALL-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] +// ALL: [[THEN]] +// ALL-NEXT: store i8 2, i8* [[A_ADDR]] +// ALL-NEXT: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: br label {{%?}}[[EXIT]] +// ALL: [[EXIT]] #pragma omp masked a = 2; -// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) -// CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 2) -// CHECK-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 -// CHECK-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] -// CHECK: [[THEN]] -// CHECK-NEXT: call {{.*}}void [[FOO]]() -// CHECK: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: br label {{%?}}[[EXIT]] -// CHECK: [[EXIT]] +// IRBUILDER: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) +// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 2) +// ALL-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 +// ALL-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] +// ALL: [[THEN]] +// IRBUILDER-NEXT: call {{.*}}void [[FOO]]() +// NORMAL-NEXT: invoke {{.*}}void [[FOO]]() +// ALL: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: br label {{%?}}[[EXIT]] +// ALL: [[EXIT]] #pragma omp masked filter(2) foo(); -// CHECK: store i32 9, i32* [[X:.+]], -// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]] -// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) -// CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 [[X_VAL]]) -// CHECK-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 -// CHECK-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] -// CHECK: [[THEN]] -// CHECK-NEXT: call {{.*}}void [[FOO]]() -// CHECK: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: br label {{%?}}[[EXIT]] -// CHECK: [[EXIT]] +// ALL: store i32 9, i32* [[X:.+]], +// ALL: [[X_VAL:%.+]] = load i32, i32* [[X]] +// IRBUILDER: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) +// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 [[X_VAL]]) +// ALL-NEXT: [[IS_MASKED:%.+]] = icmp ne i32 [[RES]], 0 +// ALL-NEXT: br i1 [[IS_MASKED]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] +// ALL: [[THEN]] +// IRBUILDER-NEXT: call {{.*}}void [[FOO]]() +// NORMAL-NEXT: invoke {{.*}}void [[FOO]]() +// ALL: call {{.*}}void @__kmpc_end_masked([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: br label {{%?}}[[EXIT]] +// ALL: [[EXIT]] int x = 9; #pragma omp masked filter(x) foo(); - // CHECK-NOT: call i32 @__kmpc_masked - // CHECK-NOT: call void @__kmpc_end_masked + // ALL-NOT: call i32 @__kmpc_masked + // ALL-NOT: call void @__kmpc_end_masked return a; } -// CHECK-LABEL: lambda_masked +// ALL-LABEL: lambda_masked // TERM_DEBUG-LABEL: lambda_masked void lambda_masked(int a, int b) { auto l = [=]() { #pragma omp masked { - // CHECK: call i32 @__kmpc_masked( + // ALL: call i32 @__kmpc_masked( int c = a + b; } }; @@ -82,7 +87,7 @@ void lambda_masked(int a, int b) { #pragma omp parallel #pragma omp masked filter(1) { - // CHECK: call i32 @__kmpc_masked( + // ALL: call i32 @__kmpc_masked( int c = a + b; } }; @@ -94,7 +99,7 @@ void lambda_masked(int a, int b) { #pragma omp parallel #pragma omp masked filter(yy) { - // CHECK: call i32 @__kmpc_masked( + // ALL: call i32 @__kmpc_masked( int c = a + b; } }; @@ -102,12 +107,12 @@ void lambda_masked(int a, int b) { l2(y); } -// CHECK-LABEL: parallel_masked +// ALL-LABEL: parallel_masked // TERM_DEBUG-LABEL: parallel_masked void parallel_masked() { #pragma omp parallel #pragma omp masked filter(1) - // TERM_DEBUG: __kmpc_global_thread_num + // TERM_DEBUG-NOT: __kmpc_global_thread_num // TERM_DEBUG: call i32 @__kmpc_masked({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]] // TERM_DEBUG: invoke void {{.*}}foo{{.*}}() // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], @@ -121,7 +126,7 @@ void parallel_masked() { int x; #pragma omp parallel #pragma omp masked filter(x) - // TERM_DEBUG: __kmpc_global_thread_num + // TERM_DEBUG-NOT: __kmpc_global_thread_num // TERM_DEBUG: call i32 @__kmpc_masked({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]] // TERM_DEBUG: invoke void {{.*}}foo{{.*}}() // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], diff --git a/clang/test/OpenMP/master_codegen.cpp b/clang/test/OpenMP/master_codegen.cpp index dfc661b..353284e 100644 --- a/clang/test/OpenMP/master_codegen.cpp +++ b/clang/test/OpenMP/master_codegen.cpp @@ -1,7 +1,10 @@ -// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s -// 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 +// 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,NORMAL // 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_DEBUG +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER +// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// 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,IRBUILDER // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s @@ -12,52 +15,53 @@ #ifndef HEADER #define HEADER -// CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } +// ALL: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } -// CHECK: define {{.*}}void [[FOO:@.+]]() +// ALL: define {{.*}}void [[FOO:@.+]]() void foo() { extern void mayThrow(); mayThrow(); } -// CHECK-LABEL: @main +// ALL-LABEL: @main // TERM_DEBUG-LABEL: @main int main() { - // CHECK: [[A_ADDR:%.+]] = alloca i8 + // ALL: [[A_ADDR:%.+]] = alloca i8 char a; -// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) -// CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 -// CHECK-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] -// CHECK: [[THEN]] -// CHECK-NEXT: store i8 2, i8* [[A_ADDR]] -// CHECK-NEXT: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: br label {{%?}}[[EXIT]] -// CHECK: [[EXIT]] +// ALL: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) +// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 +// ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] +// ALL: [[THEN]] +// ALL-NEXT: store i8 2, i8* [[A_ADDR]] +// ALL-NEXT: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: br label {{%?}}[[EXIT]] +// ALL: [[EXIT]] #pragma omp master a = 2; -// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) -// CHECK: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 -// CHECK-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] -// CHECK: [[THEN]] -// CHECK-NEXT: call {{.*}}void [[FOO]]() -// CHECK: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) -// CHECK-NEXT: br label {{%?}}[[EXIT]] -// CHECK: [[EXIT]] +// IRBUILDER: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) +// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0 +// ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] +// ALL: [[THEN]] +// IRBUILDER-NEXT: call {{.*}}void [[FOO]]() +// NORMAL-NEXT: invoke {{.*}}void [[FOO]]() +// ALL: call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) +// ALL-NEXT: br label {{%?}}[[EXIT]] +// ALL: [[EXIT]] #pragma omp master foo(); - // CHECK-NOT: call i32 @__kmpc_master - // CHECK-NOT: call void @__kmpc_end_master + // ALL-NOT: call i32 @__kmpc_master + // ALL-NOT: call void @__kmpc_end_master return a; } -// CHECK-LABEL: lambda_master +// ALL-LABEL: lambda_master // TERM_DEBUG-LABEL: lambda_master void lambda_master(int a, int b) { auto l = [=]() { #pragma omp master { - // CHECK: call i32 @__kmpc_master( + // ALL: call i32 @__kmpc_master( int c = a + b; } }; @@ -68,7 +72,7 @@ void lambda_master(int a, int b) { #pragma omp parallel #pragma omp master { - // CHECK: call i32 @__kmpc_master( + // ALL: call i32 @__kmpc_master( int c = a + b; } }; @@ -78,7 +82,7 @@ void lambda_master(int a, int b) { auto l2 = [=]() { #pragma omp parallel master { - // CHECK: call i32 @__kmpc_master( + // ALL: call i32 @__kmpc_master( int c = a + b; } }; @@ -86,12 +90,12 @@ void lambda_master(int a, int b) { l2(); } -// CHECK-LABEL: parallel_master +// ALL-LABEL: parallel_master // TERM_DEBUG-LABEL: parallel_master void parallel_master() { #pragma omp parallel #pragma omp master - // TERM_DEBUG: __kmpc_global_thread_num + // TERM_DEBUG-NOT: __kmpc_global_thread_num // TERM_DEBUG: call i32 @__kmpc_master({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]] // TERM_DEBUG: invoke void {{.*}}foo{{.*}}() // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], -- 2.7.4