[PATCH] D93205: [Flang][OpenMP 4.5] Add semantic check for OpenMP Do Loop Constructs for single directive
Yashaswini Hegde via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 11 11:53:07 PST 2021
yhegde added inline comments.
================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:527
+ if (const parser::Name * name{parser::Unwrap<parser::Name>(ompObject)}) {
+ if (name->symbol == GetContext().loopIV) {
+ context_.Say(name->source,
----------------
kiranchandramohan wrote:
> Does the context have the current directive? If so can we get the loopIV through the directive and avoid the need to store the loopIV field?
I suppose I require OpenMPLoopConstruct and DoConstruct to get loopIndex. dirContext_ gives directivesource and llvm::omp::Directive , directiveEnum.
================
Comment at: flang/lib/Semantics/check-omp-structure.cpp:153
+ case llvm::omp::OMPD_single:
+ for (const auto &dirContext : dirContext_) {
+ if (dirContext.directive == llvm::omp::Directive::OMPD_do) {
----------------
kiranchandramohan wrote:
> yhegde wrote:
> > kiranchandramohan wrote:
> > > yhegde wrote:
> > > > kiranchandramohan wrote:
> > > > > yhegde wrote:
> > > > > > clementval wrote:
> > > > > > > `dirContext_` act as a stack so do you really intent to go from the bottom of the stack to the top? If so no problem. Just asking.
> > > > > > Yes. Check on nesting is called only if Do directive present in that stack.
> > > > > Should this call to HasInvalidWorksharingNesting be similar to the one in OpenMPLoopDirective and happen before pushing the context and not iterate over the entire stack of contexts?
> > > > In OpenMPLoopDirective OMPD_Do context is pushed after calling HasInvalidWorksharingNesting. So I could not do this check in a similar way.
> > > Is there any issue with pushing the context after calling HasInvalidWorksharingNesting here also?
> > I suppose you mean pushing OMPD_Do context after calling HasInvalidWorksharingNesting ? . If so , then it is not required to push that context later. Control reaches OpenMPLoopDirective first and then OMPD_single.
> I was asking whether it is OK to implement it the following way so that we don't have to use FindInEnclosingDirContext function?
>
> ```
> if (beginDir.v == llvm::omp::Directive::OMPD_single) {
> HasInvalidWorksharingNesting(...);
> }
>
> PushContextAndClauseSets(beginDir.source, beginDir.v);
>
> switch (beginDir.v) {
> case llvm::omp::OMPD_parallel:
> CheckNoBranching(block, llvm::omp::OMPD_parallel, beginDir.source);
> break;
> default:
> break;
> }
> }
> ```
FindEnclosingDirContext function can check any restrictive directives for "single" , like "critical" or "task" - if in case it is required to check . Otherwise I can call
if (beginDir.v == llvm::omp::Directive::OMPD_single) {
HasInvalidWorksharingNesting(HasInvalidWorksharingNesting(
beginDir.source, {llvm::omp::Directive::OMPD_do}););
}
before pushing the PushContextAndClauseSets(beginDir.source, beginDir.v) and get the expected error.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93205/new/
https://reviews.llvm.org/D93205
More information about the llvm-commits
mailing list