-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][OpenMP] Fix/enforce order-concurrent-nestable rules #135463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4789,26 +4789,12 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, | |
| getLeafOrCompositeConstructs(ParentRegion, LeafOrComposite); | ||
| OpenMPDirectiveKind EnclosingConstruct = ParentLOC.back(); | ||
|
|
||
| if (Stack->isParentOrderConcurrent()) { | ||
| bool InvalidOrderNesting = false; | ||
| if ((SemaRef.LangOpts.OpenMP == 51 || SemaRef.LangOpts.OpenMP == 52) && | ||
| CurrentRegion != OMPD_simd && CurrentRegion != OMPD_loop && | ||
| CurrentRegion != OMPD_parallel && | ||
| !isOpenMPCombinedParallelADirective(CurrentRegion)) { | ||
| InvalidOrderNesting = true; | ||
| } else if (SemaRef.LangOpts.OpenMP >= 60 && | ||
| !isOpenMPOrderConcurrentNestableDirective(CurrentRegion)) { | ||
| // OpenMP 6.0 [12.3 order Clause, Restrictions] | ||
| // Only regions that correspond to order-concurrent-nestable constructs | ||
| // or order-concurrent-nestable routines may be strictly nested regions | ||
| // of regions that correspond to constructs on which the order clause is | ||
| // specified with concurrent as the ordering argument. | ||
| InvalidOrderNesting = true; | ||
| } | ||
| if (InvalidOrderNesting) { | ||
| SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order) | ||
| << getOpenMPDirectiveName(CurrentRegion); | ||
| } | ||
| if (SemaRef.LangOpts.OpenMP >= 50 && Stack->isParentOrderConcurrent() && | ||
| !isOpenMPOrderConcurrentNestableDirective(CurrentRegion, | ||
| SemaRef.LangOpts)) { | ||
| SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order) | ||
| << getOpenMPDirectiveName(CurrentRegion); | ||
| return true; | ||
| } | ||
| if (isOpenMPSimdDirective(ParentRegion) && | ||
| ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) || | ||
|
|
@@ -7132,7 +7118,7 @@ ExprResult SemaOpenMP::ActOnOpenMPCall(ExprResult Call, Scope *Scope, | |
| if (!CalleeFnDecl) | ||
| return Call; | ||
|
|
||
| if (getLangOpts().OpenMP >= 51 && getLangOpts().OpenMP < 60 && | ||
| if (getLangOpts().OpenMP >= 50 && getLangOpts().OpenMP <= 60 && | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OpenMP 5.0 and 6.0 also have the same restrictions as 5.1 and 5.2 w.r.t. OpenMP runtime APIs (e.g., |
||
| CalleeFnDecl->getIdentifier() && | ||
| CalleeFnDecl->getName().starts_with_insensitive("omp_")) { | ||
| // checking for any calls inside an Order region | ||
|
|
@@ -16373,21 +16359,20 @@ OMPClause *SemaOpenMP::ActOnOpenMPOrderClause( | |
| << getOpenMPClauseName(OMPC_order); | ||
| return nullptr; | ||
| } | ||
| if (getLangOpts().OpenMP >= 51) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Original implementation did not call |
||
| if (Modifier == OMPC_ORDER_MODIFIER_unknown && MLoc.isValid()) { | ||
| Diag(MLoc, diag::err_omp_unexpected_clause_value) | ||
| << getListOfPossibleValues(OMPC_order, | ||
| /*First=*/OMPC_ORDER_MODIFIER_unknown + 1, | ||
| /*Last=*/OMPC_ORDER_MODIFIER_last) | ||
| << getOpenMPClauseName(OMPC_order); | ||
| } else { | ||
| DSAStack->setRegionHasOrderConcurrent(/*HasOrderConcurrent=*/true); | ||
| if (DSAStack->getCurScope()) { | ||
| // mark the current scope with 'order' flag | ||
| unsigned existingFlags = DSAStack->getCurScope()->getFlags(); | ||
| DSAStack->getCurScope()->setFlags(existingFlags | | ||
| Scope::OpenMPOrderClauseScope); | ||
| } | ||
| if (getLangOpts().OpenMP >= 51 && Modifier == OMPC_ORDER_MODIFIER_unknown && | ||
| MLoc.isValid()) { | ||
| Diag(MLoc, diag::err_omp_unexpected_clause_value) | ||
| << getListOfPossibleValues(OMPC_order, | ||
| /*First=*/OMPC_ORDER_MODIFIER_unknown + 1, | ||
| /*Last=*/OMPC_ORDER_MODIFIER_last) | ||
| << getOpenMPClauseName(OMPC_order); | ||
| } else if (getLangOpts().OpenMP >= 50) { | ||
| DSAStack->setRegionHasOrderConcurrent(/*HasOrderConcurrent=*/true); | ||
| if (DSAStack->getCurScope()) { | ||
| // mark the current scope with 'order' flag | ||
| unsigned existingFlags = DSAStack->getCurScope()->getFlags(); | ||
| DSAStack->getCurScope()->setFlags(existingFlags | | ||
| Scope::OpenMPOrderClauseScope); | ||
| } | ||
| } | ||
| return new (getASTContext()) OMPOrderClause( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.