diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2015-05-05 06:21:01 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-05-05 06:21:01 +0000 |
| commit | 70542831fc29849a84f12aa4e1e3a06894479bcf (patch) | |
| tree | a993a5fe456043288df9bbde7f0302ca4e8f4b66 /clang/lib/CodeGen | |
| parent | f4497be0bbb98a6ebc00dc7ee7af4c6d56a9c9d6 (diff) | |
| download | bcm5719-llvm-70542831fc29849a84f12aa4e1e3a06894479bcf.tar.gz bcm5719-llvm-70542831fc29849a84f12aa4e1e3a06894479bcf.zip | |
[OPENMP] Fixed incorrect work with cleanups, NFC.
Destructors are never called for cleanups, so we can't use SmallVector as a member.
Differential Revision: http://reviews.llvm.org/D9399
llvm-svn: 236482
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index a0c02ce8682..84ee7ae97e1 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1154,16 +1154,16 @@ llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) { } namespace { -class CallEndCleanup : public EHScopeStack::Cleanup { -public: - typedef ArrayRef<llvm::Value *> CleanupValuesTy; -private: +template <int N> class CallEndCleanup : public EHScopeStack::Cleanup { llvm::Value *Callee; - llvm::SmallVector<llvm::Value *, 8> Args; + llvm::Value *Args[N]; public: - CallEndCleanup(llvm::Value *Callee, CleanupValuesTy Args) - : Callee(Callee), Args(Args.begin(), Args.end()) {} + CallEndCleanup(llvm::Value *Callee, ArrayRef<llvm::Value *> CleanupArgs) + : Callee(Callee) { + assert(CleanupArgs.size() == N); + std::copy(CleanupArgs.begin(), CleanupArgs.end(), std::begin(Args)); + } void Emit(CodeGenFunction &CGF, Flags /*flags*/) override { CGF.EmitRuntimeCall(Callee, Args); } @@ -1184,7 +1184,8 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF, getCriticalRegionLock(CriticalName)}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical), Args); // Build a call to __kmpc_end_critical - CGF.EHStack.pushCleanup<CallEndCleanup>( + constexpr auto Size = array_lengthof(Args); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_critical), llvm::makeArrayRef(Args)); emitInlinedDirective(CGF, CriticalOpGen); @@ -1222,7 +1223,8 @@ 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<CallEndCleanup>( + constexpr auto Size = array_lengthof(Args); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_master), llvm::makeArrayRef(Args)); MasterOpGen(CGF); @@ -1328,7 +1330,8 @@ 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<CallEndCleanup>( + constexpr auto Size = array_lengthof(Args); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_single), llvm::makeArrayRef(Args)); SingleOpGen(CGF); @@ -1391,7 +1394,8 @@ 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<CallEndCleanup>( + constexpr auto Size = array_lengthof(Args); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_ordered), llvm::makeArrayRef(Args)); emitInlinedDirective(CGF, OrderedOpGen); @@ -1999,7 +2003,8 @@ 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>( + constexpr auto Size = array_lengthof(TaskArgs); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_omp_task_complete_if0), llvm::makeArrayRef(TaskArgs)); @@ -2191,7 +2196,8 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ThreadId, // i32 <gtid> Lock // kmp_critical_name *&<lock> }; - CGF.EHStack.pushCleanup<CallEndCleanup>( + constexpr auto Size = array_lengthof(EndArgs); + CGF.EHStack.pushCleanup<CallEndCleanup<Size>>( NormalAndEHCleanup, createRuntimeFunction(WithNowait ? OMPRTL__kmpc_end_reduce_nowait : OMPRTL__kmpc_end_reduce), |

