diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2015-05-13 10:23:02 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-05-13 10:23:02 +0000 |
| commit | d130fd17f15bbdeb57003db99abff59aa5795617 (patch) | |
| tree | bc1bc14fe360ba922e6b558bd24d616ce644c3a8 /clang/lib | |
| parent | 9fb2ff71ca8aeaa1d14dcb82d0806e3779af5d68 (diff) | |
| download | bcm5719-llvm-d130fd17f15bbdeb57003db99abff59aa5795617.tar.gz bcm5719-llvm-d130fd17f15bbdeb57003db99abff59aa5795617.zip | |
[OPENMP] Fixed codegen for firstprivate variables, also marked as lastprivate.
In some rare cases shared copies of lastprivate/firstprivate variables were not updated after the loop directive.
llvm-svn: 237243
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 130f080ef08..ce1b42dbbbb 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -267,6 +267,7 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit( bool HasAtLeastOneLastprivate = false; llvm::DenseSet<const VarDecl *> AlreadyEmittedVars; for (auto &&I = D.getClausesOfKind(OMPC_lastprivate); I; ++I) { + HasAtLeastOneLastprivate = true; auto *C = cast<OMPLastprivateClause>(*I); auto IRef = C->varlist_begin(); auto IDestRef = C->destination_exprs().begin(); @@ -287,17 +288,18 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit( // Check if the variable is also a firstprivate: in this case IInit is // not generated. Initialization of this variable will happen in codegen // for 'firstprivate' clause. - if (!IInit) - continue; - auto *VD = cast<VarDecl>(cast<DeclRefExpr>(IInit)->getDecl()); - bool IsRegistered = - PrivateScope.addPrivate(OrigVD, [&]() -> llvm::Value *{ - // Emit private VarDecl with copy init. - EmitDecl(*VD); - return GetAddrOfLocalVar(VD); - }); - assert(IsRegistered && "lastprivate var already registered as private"); - HasAtLeastOneLastprivate = HasAtLeastOneLastprivate || IsRegistered; + if (IInit) { + auto *VD = cast<VarDecl>(cast<DeclRefExpr>(IInit)->getDecl()); + bool IsRegistered = + PrivateScope.addPrivate(OrigVD, [&]() -> llvm::Value *{ + // Emit private VarDecl with copy init. + EmitDecl(*VD); + return GetAddrOfLocalVar(VD); + }); + assert(IsRegistered && + "lastprivate var already registered as private"); + (void)IsRegistered; + } } ++IRef, ++IDestRef; } |

