diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2018-11-21 19:41:10 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-11-21 19:41:10 +0000 |
| commit | 92b33652f6b208cc8e5a1a39472f2549a45de76a (patch) | |
| tree | 50fe70935073c843df5370cdc109b725f42aeed4 /clang/lib | |
| parent | da6bc702d07ce9aa7dc43f6a29fd6f23cbfb6857 (diff) | |
| download | bcm5719-llvm-92b33652f6b208cc8e5a1a39472f2549a45de76a.tar.gz bcm5719-llvm-92b33652f6b208cc8e5a1a39472f2549a45de76a.zip | |
[OPENMP]Fix handling of the LCVs in loop-based directives.
Loop-control variables with the default data-sharing attributes should
not be captured in the OpenMP region as they are private by default.
Also, default attributes should be emitted for such variables in the
inner OpenMP regions for the correct data sharing during codegen.
llvm-svn: 347409
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index a2a935944c1..84c3023081a 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1275,10 +1275,16 @@ bool DSAStackTy::hasExplicitDSA( return false; std::advance(StartI, Level); auto I = StartI->SharingMap.find(D); - return (I != StartI->SharingMap.end()) && + if ((I != StartI->SharingMap.end()) && I->getSecond().RefExpr.getPointer() && CPred(I->getSecond().Attributes) && - (!NotLastprivate || !I->getSecond().RefExpr.getInt()); + (!NotLastprivate || !I->getSecond().RefExpr.getInt())) + return true; + // Check predetermined rules for the loop control variables. + auto LI = StartI->LCVMap.find(D); + if (LI != StartI->LCVMap.end()) + return CPred(OMPC_private); + return false; } bool DSAStackTy::hasExplicitDirective( diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index e99d75cdcf4..4011ec251cf 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6770,6 +6770,9 @@ TreeTransform<Derived>::TransformDoStmt(DoStmt *S) { template<typename Derived> StmtResult TreeTransform<Derived>::TransformForStmt(ForStmt *S) { + if (getSema().getLangOpts().OpenMP) + getSema().startOpenMPLoop(); + // Transform the initialization statement StmtResult Init = getDerived().TransformStmt(S->getInit()); if (Init.isInvalid()) |

