diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-06-23 04:51:00 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-06-23 04:51:00 +0000 |
commit | aac108a324dd0478afa349cd756c2a7c4d6e97ea (patch) | |
tree | 8749a74fbf007027d917cf8b7ac69d82a8dfe9a6 /clang/lib/Sema/SemaExpr.cpp | |
parent | 9ad0ec295fa571e32bfa22e231caddf3c532e463 (diff) | |
download | bcm5719-llvm-aac108a324dd0478afa349cd756c2a7c4d6e97ea.tar.gz bcm5719-llvm-aac108a324dd0478afa349cd756c2a7c4d6e97ea.zip |
[OPENMP] Do not emit references to original variables in 'private' clause.
Currently if the variable is captured in captured region, capture record for this region stores reference to this variable for future use. But we don't need to provide the reference to the original variable if it was explicitly marked as private in the 'private' clause of the OpenMP construct, this variable is replaced by private copy.
Differential Revision: http://reviews.llvm.org/D9550
llvm-svn: 240377
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ffa47eeb587..2d2cadab9a3 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -12741,6 +12741,7 @@ bool Sema::tryCaptureVariable( bool Nested = false; bool Explicit = (Kind != TryCapture_Implicit); unsigned FunctionScopesIndex = MaxFunctionScopesIndex; + unsigned OpenMPLevel = 0; do { // Only block literals, captured statements, and lambda expressions can // capture; other scopes don't work. @@ -12767,6 +12768,20 @@ bool Sema::tryCaptureVariable( if (isVariableAlreadyCapturedInScopeInfo(CSI, Var, Nested, CaptureType, DeclRefType)) break; + if (getLangOpts().OpenMP) { + if (auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) { + // OpenMP private variables should not be captured in outer scope, so + // just break here. + if (RSI->CapRegionKind == CR_OpenMP) { + if (isOpenMPPrivateVar(Var, OpenMPLevel)) { + Nested = true; + CaptureType = Context.getLValueReferenceType(DeclRefType); + break; + } + ++OpenMPLevel; + } + } + } // If we are instantiating a generic lambda call operator body, // we do not want to capture new variables. What was captured // during either a lambdas transformation or initial parsing |