summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-06-25 06:52:00 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-06-25 06:52:00 +0000
commit3f3078bf289bec6116f4b43221e8aa7609106405 (patch)
treeea341fc59b6eddf8137f07681839c174ea360793 /lib/Sema/SemaOpenMP.cpp
parente74fa2a6cd5e37067db371fbffd7f6c9e7491b61 (diff)
downloadclang-3f3078bf289bec6116f4b43221e8aa7609106405.tar.gz
clang-3f3078bf289bec6116f4b43221e8aa7609106405.tar.bz2
clang-3f3078bf289bec6116f4b43221e8aa7609106405.tar.xz
[OPENMP] OMPSimdDirective and OMPForDirective: added initialization for CollapsedNum member.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r--lib/Sema/SemaOpenMP.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index 5cf47c0ac1..aef7ae5a59 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -1500,8 +1500,11 @@ static Stmt *IgnoreContainerStmts(Stmt *S, bool IgnoreCaptured) {
}
/// \brief Called on a for stmt to check itself and nested loops (if any).
-static bool CheckOpenMPLoop(OpenMPDirectiveKind DKind, Expr *NestedLoopCountExpr,
- Stmt *AStmt, Sema &SemaRef, DSAStackTy &DSA) {
+/// \return Returns 0 if one of the collapsed stmts is not canonical for loop,
+/// number of collapsed loops otherwise.
+static unsigned CheckOpenMPLoop(OpenMPDirectiveKind DKind,
+ Expr *NestedLoopCountExpr, Stmt *AStmt,
+ Sema &SemaRef, DSAStackTy &DSA) {
unsigned NestedLoopCount = 1;
if (NestedLoopCountExpr) {
// Found 'collapse' clause - calculate collapse number.
@@ -1515,14 +1518,14 @@ static bool CheckOpenMPLoop(OpenMPDirectiveKind DKind, Expr *NestedLoopCountExpr
for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) {
if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt,
NestedLoopCount, NestedLoopCountExpr))
- return true;
+ return 0;
// Move on to the next nested for loop, or to the loop body.
CurStmt = IgnoreContainerStmts(cast<ForStmt>(CurStmt)->getBody(), false);
}
// FIXME: Build resulting iteration space for IR generation (collapsing
// iteration spaces when loop count > 1 ('collapse' clause)).
- return false;
+ return NestedLoopCount;
}
static Expr *GetCollapseNumberExpr(ArrayRef<OMPClause *> Clauses) {
@@ -1540,24 +1543,28 @@ StmtResult Sema::ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc) {
// In presence of clause 'collapse', it will define the nested loops number.
- if (CheckOpenMPLoop(OMPD_simd, GetCollapseNumberExpr(Clauses),
- AStmt, *this, *DSAStack))
+ unsigned NestedLoopCount = CheckOpenMPLoop(
+ OMPD_simd, GetCollapseNumberExpr(Clauses), AStmt, *this, *DSAStack);
+ if (NestedLoopCount == 0)
return StmtError();
getCurFunction()->setHasBranchProtectedScope();
- return OMPSimdDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
+ return OMPSimdDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
+ Clauses, AStmt);
}
StmtResult Sema::ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc) {
// In presence of clause 'collapse', it will define the nested loops number.
- if (CheckOpenMPLoop(OMPD_for, GetCollapseNumberExpr(Clauses),
- AStmt, *this, *DSAStack))
+ unsigned NestedLoopCount = CheckOpenMPLoop(
+ OMPD_for, GetCollapseNumberExpr(Clauses), AStmt, *this, *DSAStack);
+ if (NestedLoopCount == 0)
return StmtError();
getCurFunction()->setHasBranchProtectedScope();
- return OMPForDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
+ return OMPForDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
+ Clauses, AStmt);
}
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,