From ce348a49b42d359ee823e741651d83f460f9f736 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 5 May 2015 08:48:39 +0000 Subject: [PATCH] Revert revision 236487: [OPENMP] Fixed incorrect work with cleanups, NFC. llvm-svn: 236490 --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 654a4eb..a0c02ce 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1154,16 +1154,16 @@ llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) { } namespace { -template class CallEndCleanup : public EHScopeStack::Cleanup { +class CallEndCleanup : public EHScopeStack::Cleanup { +public: + typedef ArrayRef CleanupValuesTy; +private: llvm::Value *Callee; - llvm::Value *Args[N]; + llvm::SmallVector Args; public: - CallEndCleanup(llvm::Value *Callee, ArrayRef CleanupArgs) - : Callee(Callee) { - assert(CleanupArgs.size() == N); - std::copy(CleanupArgs.begin(), CleanupArgs.end(), std::begin(Args)); - } + CallEndCleanup(llvm::Value *Callee, CleanupValuesTy Args) + : Callee(Callee), Args(Args.begin(), Args.end()) {} void Emit(CodeGenFunction &CGF, Flags /*flags*/) override { CGF.EmitRuntimeCall(Callee, Args); } @@ -1184,7 +1184,7 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF, getCriticalRegionLock(CriticalName)}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical), Args); // Build a call to __kmpc_end_critical - CGF.EHStack.pushCleanup::value>>( + CGF.EHStack.pushCleanup( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_critical), llvm::makeArrayRef(Args)); emitInlinedDirective(CGF, CriticalOpGen); @@ -1222,7 +1222,7 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_master), Args); emitIfStmt(CGF, IsMaster, [&](CodeGenFunction &CGF) -> void { CodeGenFunction::RunCleanupsScope Scope(CGF); - CGF.EHStack.pushCleanup::value>>( + CGF.EHStack.pushCleanup( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_master), llvm::makeArrayRef(Args)); MasterOpGen(CGF); @@ -1328,7 +1328,7 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_single), Args); emitIfStmt(CGF, IsSingle, [&](CodeGenFunction &CGF) -> void { CodeGenFunction::RunCleanupsScope Scope(CGF); - CGF.EHStack.pushCleanup::value>>( + CGF.EHStack.pushCleanup( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_single), llvm::makeArrayRef(Args)); SingleOpGen(CGF); @@ -1391,7 +1391,7 @@ void CGOpenMPRuntime::emitOrderedRegion(CodeGenFunction &CGF, llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_ordered), Args); // Build a call to __kmpc_end_ordered - CGF.EHStack.pushCleanup::value>>( + CGF.EHStack.pushCleanup( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_ordered), llvm::makeArrayRef(Args)); emitInlinedDirective(CGF, OrderedOpGen); @@ -1999,8 +1999,7 @@ void CGOpenMPRuntime::emitTaskCall( createRuntimeFunction(OMPRTL__kmpc_omp_task_begin_if0), TaskArgs); // Build void __kmpc_omp_task_complete_if0(ident_t *, kmp_int32 gtid, // kmp_task_t *new_task); - CGF.EHStack.pushCleanup< - CallEndCleanup::value>>( + CGF.EHStack.pushCleanup( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_omp_task_complete_if0), llvm::makeArrayRef(TaskArgs)); @@ -2192,12 +2191,11 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ThreadId, // i32 Lock // kmp_critical_name *& }; - CGF.EHStack - .pushCleanup::value>>( - NormalAndEHCleanup, - createRuntimeFunction(WithNowait ? OMPRTL__kmpc_end_reduce_nowait - : OMPRTL__kmpc_end_reduce), - llvm::makeArrayRef(EndArgs)); + CGF.EHStack.pushCleanup( + NormalAndEHCleanup, + createRuntimeFunction(WithNowait ? OMPRTL__kmpc_end_reduce_nowait + : OMPRTL__kmpc_end_reduce), + llvm::makeArrayRef(EndArgs)); for (auto *E : ReductionOps) { CGF.EmitIgnoredExpr(E); } -- 2.7.4