From: Alexey Bataev Date: Fri, 10 Apr 2015 07:48:12 +0000 (+0000) Subject: [OPENMP] Fixed cleanup of OpenMP code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23fcb92dd1a5ec92df56b19fdd703447f65c03c4;p=clang [OPENMP] Fixed cleanup of OpenMP code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234575 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index f3a575f117..2b9fbd6661 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -970,12 +970,18 @@ llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) { namespace { class CallEndCleanup : public EHScopeStack::Cleanup { +public: + typedef ArrayRef CleanupValuesTy; private: - const RegionCodeGenTy CodeGen; + llvm::Value *Callee; + llvm::SmallVector Args; public: - CallEndCleanup(const RegionCodeGenTy &CodeGen) : CodeGen(CodeGen) {} - void Emit(CodeGenFunction &CGF, Flags /*flags*/) override { CodeGen(CGF); } + CallEndCleanup(llvm::Value *Callee, CleanupValuesTy Args) + : Callee(Callee), Args(Args.begin(), Args.end()) {} + void Emit(CodeGenFunction &CGF, Flags /*flags*/) override { + CGF.EmitRuntimeCall(Callee, Args); + } }; } // namespace @@ -995,15 +1001,8 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF, emitInlinedDirective(CGF, CriticalOpGen); // Build a call to __kmpc_end_critical CGF.EHStack.pushCleanup( - NormalAndEHCleanup, [Loc, CriticalName](CodeGenFunction &CGF) { - llvm::Value *Args[] = { - CGF.CGM.getOpenMPRuntime().emitUpdateLocation(CGF, Loc), - CGF.CGM.getOpenMPRuntime().getThreadID(CGF, Loc), - CGF.CGM.getOpenMPRuntime().getCriticalRegionLock(CriticalName)}; - CGF.EmitRuntimeCall(CGF.CGM.getOpenMPRuntime().createRuntimeFunction( - OMPRTL__kmpc_end_critical), - Args); - }); + NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_critical), + llvm::makeArrayRef(Args)); } } @@ -1056,14 +1055,8 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, // fallthrough rather than pushing a normal cleanup for it. // Build a call to __kmpc_end_critical CGF.EHStack.pushCleanup( - NormalAndEHCleanup, [Loc](CodeGenFunction &CGF) { - llvm::Value *Args[] = { - CGF.CGM.getOpenMPRuntime().emitUpdateLocation(CGF, Loc), - CGF.CGM.getOpenMPRuntime().getThreadID(CGF, Loc)}; - CGF.EmitRuntimeCall(CGF.CGM.getOpenMPRuntime().createRuntimeFunction( - OMPRTL__kmpc_end_master), - Args); - }); + NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_master), + llvm::makeArrayRef(Args)); }); } @@ -1195,14 +1188,8 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, // It is analyzed in Sema, so we can just call __kmpc_end_single() on // fallthrough rather than pushing a normal cleanup for it. CGF.EHStack.pushCleanup( - NormalAndEHCleanup, [Loc](CodeGenFunction &CGF) { - llvm::Value *Args[] = { - CGF.CGM.getOpenMPRuntime().emitUpdateLocation(CGF, Loc), - CGF.CGM.getOpenMPRuntime().getThreadID(CGF, Loc)}; - CGF.EmitRuntimeCall(CGF.CGM.getOpenMPRuntime().createRuntimeFunction( - OMPRTL__kmpc_end_single), - Args); - }); + NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_single), + llvm::makeArrayRef(Args)); }); // call __kmpc_copyprivate(ident_t *, gtid, , , // , did_it);