diff options
author | Samuel Antao <sfantao@us.ibm.com> | 2015-10-02 17:14:03 +0000 |
---|---|---|
committer | Samuel Antao <sfantao@us.ibm.com> | 2015-10-02 17:14:03 +0000 |
commit | 4be30e92dc1a3f2df67d2a03c9b3b1cda55cc5cf (patch) | |
tree | b670ea594cebf892ef2872b7927623e4e19d1db3 /clang/lib/Sema/SemaExpr.cpp | |
parent | 1f385618c018b57fd0c32e125954c4dc32dfb936 (diff) | |
download | bcm5719-llvm-4be30e92dc1a3f2df67d2a03c9b3b1cda55cc5cf.tar.gz bcm5719-llvm-4be30e92dc1a3f2df67d2a03c9b3b1cda55cc5cf.zip |
[OpenMP] Capture global variables in target regions.
All global variables that are not enclosed in a declare target region
must be captured in the target region as local variables do. Currently,
there is no support for declare target, so this patch adds support for
capturing all the global variables used in a the target region.
llvm-svn: 249154
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index be0da09f265..0aa9a6c53cd 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -13183,10 +13183,18 @@ bool Sema::tryCaptureVariable( if (getLangOpts().OpenMP) { if (auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) { // OpenMP private variables should not be captured in outer scope, so - // just break here. + // just break here. Similarly, global variables that are captured in a + // target region should not be captured outside the scope of the region. if (RSI->CapRegionKind == CR_OpenMP) { - if (isOpenMPPrivateVar(Var, OpenMPLevel)) { - Nested = true; + auto isTargetCap = isOpenMPTargetCapturedVar(Var, OpenMPLevel); + // When we detect target captures we are looking from inside the + // target region, therefore we need to propagate the capture from the + // enclosing region. Therefore, the capture is not initially nested. + if (isTargetCap) + FunctionScopesIndex--; + + if (isTargetCap || isOpenMPPrivateVar(Var, OpenMPLevel)) { + Nested = !isTargetCap; DeclRefType = DeclRefType.getUnqualifiedType(); CaptureType = Context.getLValueReferenceType(DeclRefType); break; |