diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-08-18 08:26:59 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-08-18 08:26:59 +0000 |
| commit | 5a4cb1eb0c4e2560397c009da45d57bb1ebb6135 (patch) | |
| tree | 4b0e7bd16ff6d9639594693aca2d6931a71b1dec /lib/CodeGen/CGStmtOpenMP.cpp | |
| parent | 46faa67da1d7e9450e8fa363f6633e2c68e33ff1 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/CGStmtOpenMP.cpp')
| -rw-r--r-- | lib/CodeGen/CGStmtOpenMP.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
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<OMPOrderedClause>()) { + if (!C->getNumForLoops()) + continue; + for (unsigned I = S.getCollapsedNumber(), + E = C->getLoopNumIterations().size(); + I < E; ++I) { + const auto *DRE = cast<DeclRefExpr>(C->getLoopCunter(I)); + const auto *VD = cast<VarDecl>(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<OMPOrderedClause>()) { 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<OMPOrderedClause>()) { + if (!C->getNumForLoops()) + continue; + for (unsigned I = LD->getCollapsedNumber(), + E = C->getLoopNumIterations().size(); + I < E; ++I) { + if (const auto *VD = dyn_cast<OMPCapturedExprDecl>( + cast<DeclRefExpr>(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()); } |
