summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-04-25 16:21:13 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-04-25 16:21:13 +0000
commit95b64a39967af2818c21254a8e1992a0e0e07c47 (patch)
treed55831c1985713a343df7a6dab9c193eeb2739c1 /lib/Sema/SemaOpenMP.cpp
parent9981cdc9924fb8b614e60aef543372a47d12699e (diff)
downloadclang-95b64a39967af2818c21254a8e1992a0e0e07c47.tar.gz
[OPENMP] Improved check for the linear dependency in the non-rectangular
loop nests. Added a checks that the initializer/condition expressions depend only only of the single previous loop iteration variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r--lib/Sema/SemaOpenMP.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index a5afce42cb..8aaa1848a6 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -4715,6 +4715,7 @@ class LoopCounterRefChecker final
Sema &SemaRef;
DSAStackTy &Stack;
const ValueDecl *CurLCDecl = nullptr;
+ const ValueDecl *DepDecl = nullptr;
bool IsInitializer = true;
public:
@@ -4728,6 +4729,18 @@ public:
return false;
}
const auto &&Data = Stack.isLoopControlVariable(VD);
+ if (DepDecl && Data.first) {
+ SmallString<128> Name;
+ llvm::raw_svector_ostream OS(Name);
+ DepDecl->getNameForDiagnostic(OS, SemaRef.getPrintingPolicy(),
+ /*Qualified=*/true);
+ SemaRef.Diag(E->getExprLoc(),
+ diag::err_omp_invariant_or_linear_dependancy)
+ << OS.str();
+ return false;
+ }
+ if (Data.first)
+ DepDecl = VD;
return Data.first;
}
return false;
@@ -4742,16 +4755,27 @@ public:
return false;
}
const auto &&Data = Stack.isLoopControlVariable(VD);
+ if (DepDecl && Data.first) {
+ SmallString<128> Name;
+ llvm::raw_svector_ostream OS(Name);
+ DepDecl->getNameForDiagnostic(OS, SemaRef.getPrintingPolicy(),
+ /*Qualified=*/true);
+ SemaRef.Diag(E->getExprLoc(),
+ diag::err_omp_invariant_or_linear_dependancy)
+ << OS.str();
+ return false;
+ }
+ if (Data.first)
+ DepDecl = VD;
return Data.first;
}
return false;
}
bool VisitStmt(const Stmt *S) {
- for (const Stmt *Child : S->children()) {
- if (Child && Visit(Child))
- return true;
- }
- return false;
+ bool Res = true;
+ for (const Stmt *Child : S->children())
+ Res = Child && Visit(Child) && Res;
+ return Res;
}
explicit LoopCounterRefChecker(Sema &SemaRef, DSAStackTy &Stack,
const ValueDecl *CurLCDecl, bool IsInitializer)