From 2e0cbe509242697caec4a119b323475c4d006486 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 8 Mar 2018 15:24:08 +0000 Subject: [OPENMP] Emit sizes/init ptrs etc. data for task reductions before using. We may emit the code in wrong order because of incorrect implementation of the runtime functions for task reductions. Threadprivate storages may be initialized after real initialization of the reduction items. Patch fixes this problem. llvm-svn: 327008 --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'clang/lib/CodeGen/CGStmtOpenMP.cpp') diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 8d1f9c6f7b7..957bcc43db0 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -2886,6 +2886,11 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( for (unsigned Cnt = 0, E = Data.ReductionVars.size(); Cnt < E; ++Cnt) { RedCG.emitSharedLValue(CGF, Cnt); RedCG.emitAggregateType(CGF, Cnt); + // FIXME: This must removed once the runtime library is fixed. + // Emit required threadprivate variables for + // initilizer/combiner/finalizer. + CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF, S.getLocStart(), + RedCG, Cnt); Address Replacement = CGF.CGM.getOpenMPRuntime().getTaskReductionItem( CGF, S.getLocStart(), ReductionsPtr, RedCG.getSharedLValue(Cnt)); Replacement = @@ -2898,11 +2903,6 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Replacement = RedCG.adjustPrivateAddress(CGF, Cnt, Replacement); Scope.addPrivate(RedCG.getBaseDecl(Cnt), [Replacement]() { return Replacement; }); - // FIXME: This must removed once the runtime library is fixed. - // Emit required threadprivate variables for - // initilizer/combiner/finalizer. - CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF, S.getLocStart(), - RedCG, Cnt); } } // Privatize all private variables except for in_reduction items. @@ -2935,6 +2935,11 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( RedCG.emitAggregateType(CGF, Cnt); // The taskgroup descriptor variable is always implicit firstprivate and // privatized already during procoessing of the firstprivates. + // FIXME: This must removed once the runtime library is fixed. + // Emit required threadprivate variables for + // initilizer/combiner/finalizer. + CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF, S.getLocStart(), + RedCG, Cnt); llvm::Value *ReductionsPtr = CGF.EmitLoadOfScalar(CGF.EmitLValue(TaskgroupDescriptors[Cnt]), TaskgroupDescriptors[Cnt]->getExprLoc()); @@ -2949,11 +2954,6 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Replacement = RedCG.adjustPrivateAddress(CGF, Cnt, Replacement); InRedScope.addPrivate(RedCG.getBaseDecl(Cnt), [Replacement]() { return Replacement; }); - // FIXME: This must removed once the runtime library is fixed. - // Emit required threadprivate variables for - // initilizer/combiner/finalizer. - CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF, S.getLocStart(), - RedCG, Cnt); } } (void)InRedScope.Privatize(); -- cgit v1.2.3