[PATCH] [OPENMP] Bugfix for processing of global variables in OpenMP regions.
John McCall
rjmccall at gmail.com
Tue Dec 9 20:53:01 PST 2014
Sorry, lost track of it. Thanks for pinging.
================
Comment at: lib/CodeGen/CGExpr.cpp:1912
@@ +1911,3 @@
+ }
+ } else if (auto BD = dyn_cast_or_null<BlockDecl>(CurCodeDecl))
+ if (BD->capturesVariable(VD))
----------------
This should be exhaustive, right? In what situation can we have a DRE that refersToCapturedVariable() and we're not in a lambda, captured statement, or block?
If so, you should just use cast<> here.
================
Comment at: lib/Sema/SemaExpr.cpp:12141
@@ +12140,3 @@
+ if (!ParentDC) {
+ if (!Var->hasLocalStorage()) {
+ FunctionScopesIndex = MaxFunctionScopesIndex - 1;
----------------
I think this is correct, but it deserves a comment. We need to check for the parent *first* because, if we *have* private-captured a global variable, we need to recursively capture it in intermediate blocks, lambdas, etc.
Also, instead of recomputing hasLocalStorage(), please remember it from above.
================
Comment at: lib/Sema/SemaExpr.cpp:12373
@@ -12365,1 +12372,3 @@
+bool Sema::NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc) {
+ QualType CaptureType;
----------------
This method name suggests that it's non-state-changing, but I'm pretty sure that tryCaptureVariable isn't. Why do you need this routine at all?
================
Comment at: lib/Sema/SemaOpenMP.cpp:555
@@ +554,3 @@
+bool Sema::IsOpenMPCapturedVar(VarDecl *VD) {
+ if (LangOpts.OpenMP && DSAStack->getCurrentDirective() != OMPD_unknown) {
+ auto DVarPrivate = DSAStack->getTopDSA(VD, /*FromParent=*/false);
----------------
Just assert LangOpts.OpenMP.
http://reviews.llvm.org/D6259
More information about the cfe-commits
mailing list