This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Add support for getting parent context and clauses and modify the relevant sema checks to use the new functions.
ClosedPublic

Authored by arnamoy10 on Mar 13 2021, 6:26 AM.

Details

Summary

rGa59665930b87 introduced a different algorithm to check context nesting. With each nested context, we push an entry in the dirContext_ vector. Therefore intuitively, a the current context should be considered nested when the size of the vector is at least 2 e.g.

!$ omp do  --> context pushed in vector, size 1
  !$omp single --> context pushed in vector, size 2

With the change introduced in rGa59665930b87 , 4 test cases were failing. Those tests were to do with nesting checking, BUT the nesting check was being done BEFORE pushing the current context into the vector. That was counterintuitive.

This patch fixes the code (that was causing test failure) and uses the more intuitive structure of ALWAYS pushing the context first while visiting a construct, and then implement checks that are dependent on nesting check.

Also introduces helper functions for getting the parent context and checking whether a clause is present in the parent context.

These helper functions help in the implementation of more sema checks that requires getting information about the parent context.

Diff Detail

Event Timeline

arnamoy10 created this revision.Mar 13 2021, 6:26 AM
arnamoy10 requested review of this revision.Mar 13 2021, 6:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
arnamoy10 updated this revision to Diff 330450.Mar 13 2021, 6:33 AM

Clang-formatting

LGTM. Approving quickly since it fixes failures. Might need to do a recce and check that usage is consistent.

flang/lib/Semantics/check-directive-structure.h
155

Nit: Are both checks necessary, given that the second includes the first?

This revision is now accepted and ready to land.Mar 13 2021, 8:31 AM
bryanpkc added inline comments.Mar 13 2021, 9:48 AM
flang/lib/Semantics/check-directive-structure.h
207

Nit: No need to wrap line here, or the comment below for FindClauseParent.

arnamoy10 updated this revision to Diff 330478.Mar 13 2021, 2:49 PM

Addressing reviewers' comments.

This revision was landed with ongoing or failed builds.Mar 13 2021, 2:51 PM
This revision was automatically updated to reflect the committed changes.