From 5a4cb1eb0c4e2560397c009da45d57bb1ebb6135 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 18 Aug 2018 08:26:59 +0000 Subject: Vendor import of clang release_70 branch r339999: https://llvm.org/svn/llvm-project/cfe/branches/release_70@339999 --- lib/CodeGen/CGStmtOpenMP.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGStmtOpenMP.cpp') diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp index 0d343f84c71f..03102f04aa9c 100644 --- a/lib/CodeGen/CGStmtOpenMP.cpp +++ b/lib/CodeGen/CGStmtOpenMP.cpp @@ -1509,6 +1509,23 @@ void CodeGenFunction::EmitOMPPrivateLoopCounters( } ++I; } + // Privatize extra loop counters used in loops for ordered(n) clauses. + for (const auto *C : S.getClausesOfKind()) { + if (!C->getNumForLoops()) + continue; + for (unsigned I = S.getCollapsedNumber(), + E = C->getLoopNumIterations().size(); + I < E; ++I) { + const auto *DRE = cast(C->getLoopCunter(I)); + const auto *VD = cast(DRE->getDecl()); + // Override only those variables that are really emitted already. + if (LocalDeclMap.count(VD)) { + (void)LoopScope.addPrivate(VD, [this, DRE, VD]() { + return CreateMemTemp(DRE->getType(), VD->getName()); + }); + } + } + } } static void emitPreCond(CodeGenFunction &CGF, const OMPLoopDirective &S, @@ -2244,7 +2261,7 @@ bool CodeGenFunction::EmitOMPWorksharingLoop( bool Ordered = false; if (const auto *OrderedClause = S.getSingleClause()) { if (OrderedClause->getNumForLoops()) - RT.emitDoacrossInit(*this, S); + RT.emitDoacrossInit(*this, S, OrderedClause->getLoopNumIterations()); else Ordered = true; } @@ -4943,6 +4960,20 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective( CGF.EmitVarDecl(*VD); } } + for (const auto *C : D.getClausesOfKind()) { + if (!C->getNumForLoops()) + continue; + for (unsigned I = LD->getCollapsedNumber(), + E = C->getLoopNumIterations().size(); + I < E; ++I) { + if (const auto *VD = dyn_cast( + cast(C->getLoopCunter(I))->getDecl())) { + // Emit only those that were not explicitly referenced in clauses. + if (!CGF.LocalDeclMap.count(VD)) + CGF.EmitVarDecl(*VD); + } + } + } } CGF.EmitStmt(D.getInnermostCapturedStmt()->getCapturedStmt()); } -- cgit v1.3