diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-10-16 18:09:37 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-10-16 18:09:37 +0000 |
commit | bdbeb873a38db5640831d9110ae45ae50a5a65d5 (patch) | |
tree | 058971113c0cebe30d9685369d423c8a0c3ad078 /lib | |
parent | 4da6acb783d62e0d65c3543e874fd8e883ed3370 (diff) |
[OPENMP]Allow priority clause in combined task-based directives.
The expression of the priority clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/OpenMPClause.cpp | 9 | ||||
-rw-r--r-- | lib/AST/StmtProfile.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaOpenMP.cpp | 23 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 1 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 1 |
5 files changed, 21 insertions, 14 deletions
diff --git a/lib/AST/OpenMPClause.cpp b/lib/AST/OpenMPClause.cpp index ccb3cd3436..fe1334469d 100644 --- a/lib/AST/OpenMPClause.cpp +++ b/lib/AST/OpenMPClause.cpp @@ -90,6 +90,8 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { return static_cast<const OMPNumTasksClause *>(C); case OMPC_final: return static_cast<const OMPFinalClause *>(C); + case OMPC_priority: + return static_cast<const OMPPriorityClause *>(C); case OMPC_default: case OMPC_proc_bind: case OMPC_safelen: @@ -117,7 +119,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { case OMPC_threads: case OMPC_simd: case OMPC_map: - case OMPC_priority: case OMPC_nogroup: case OMPC_hint: case OMPC_defaultmap: @@ -255,6 +256,12 @@ OMPClause::child_range OMPFinalClause::used_children() { return child_range(&Condition, &Condition + 1); } +OMPClause::child_range OMPPriorityClause::used_children() { + if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) + return child_range(C, C + 1); + return child_range(&Priority, &Priority + 1); +} + OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index e536abfe35..1cc36623d4 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -737,6 +737,7 @@ void OMPClauseProfiler::VisitOMPThreadLimitClause( Profiler->VisitStmt(C->getThreadLimit()); } void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { + VistOMPClauseWithPreInit(C); if (C->getPriority()) Profiler->VisitStmt(C->getPriority()); } diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index b3f711bc7f..3000469b0c 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -4591,16 +4591,9 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( case OMPC_schedule: break; case OMPC_grainsize: - // Do not analyze if no parent parallel directive. - if (isOpenMPParallelDirective(DSAStack->getCurrentDirective())) - break; - continue; case OMPC_num_tasks: - // Do not analyze if no parent parallel directive. - if (isOpenMPParallelDirective(DSAStack->getCurrentDirective())) - break; - continue; case OMPC_final: + case OMPC_priority: // Do not analyze if no parent parallel directive. if (isOpenMPParallelDirective(DSAStack->getCurrentDirective())) break; @@ -4609,7 +4602,6 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( case OMPC_device: case OMPC_num_teams: case OMPC_thread_limit: - case OMPC_priority: case OMPC_hint: case OMPC_collapse: case OMPC_safelen: @@ -10788,6 +10780,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPC_grainsize: case OMPC_num_tasks: case OMPC_final: + case OMPC_priority: switch (DKind) { case OMPD_task: case OMPD_taskloop: @@ -10888,7 +10881,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPC_threads: case OMPC_simd: case OMPC_map: - case OMPC_priority: case OMPC_nogroup: case OMPC_hint: case OMPC_defaultmap: @@ -15937,14 +15929,19 @@ OMPClause *Sema::ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation LParenLoc, SourceLocation EndLoc) { Expr *ValExpr = Priority; + Stmt *HelperValStmt = nullptr; + OpenMPDirectiveKind CaptureRegion = OMPD_unknown; // OpenMP [2.9.1, task Constrcut] // The priority-value is a non-negative numerical scalar expression. - if (!isNonNegativeIntegerValue(ValExpr, *this, OMPC_priority, - /*StrictlyPositive=*/false)) + if (!isNonNegativeIntegerValue( + ValExpr, *this, OMPC_priority, + /*StrictlyPositive=*/false, /*BuildCapture=*/true, + DSAStack->getCurrentDirective(), &CaptureRegion, &HelperValStmt)) return nullptr; - return new (Context) OMPPriorityClause(ValExpr, StartLoc, LParenLoc, EndLoc); + return new (Context) OMPPriorityClause(ValExpr, HelperValStmt, CaptureRegion, + StartLoc, LParenLoc, EndLoc); } OMPClause *Sema::ActOnOpenMPGrainsizeClause(Expr *Grainsize, diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index dc653039f5..2d3884ebe0 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -12996,6 +12996,7 @@ void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { } void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { + VisitOMPClauseWithPreInit(C); C->setPriority(Record.readSubExpr()); C->setLParenLoc(Record.readSourceLocation()); } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 1e76c328a1..6f3b367aed 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -6977,6 +6977,7 @@ void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { } void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) { + VisitOMPClauseWithPreInit(C); Record.AddStmt(C->getPriority()); Record.AddSourceLocation(C->getLParenLoc()); } |