-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added OpenMP 5.0 specification based semantic checks for CRITICAL con… #1128
base: fir-dev
Are you sure you want to change the base?
Conversation
@kiranchandramohan @clementval Could you please see if this is fine? All of the parser changes have already been done in NimishMishra@7a22c26 , so those are skipped |
I get compilation failures with this patch. check-omp-structure.cpp:1020:65: error: ?const struct Fortran::parser::Verbatim? has no member named ?t?
const auto &dirName{std::get<std::optional<parser::Name>>(dir.t)};
^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not compile.
I assume there is something that needs to be chery-picked from main here.
I cannot compile either. |
Fixed build failures. @kiranchandramohan @schweitzpgi it is compiling for me now. Please check once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have a build failure. See inline comment.
Also, have two failed tests after fixing the build failure.
Failed Tests (2):
Flang :: Lower/OpenMP/critical.f90
Flang :: Semantics/omp-sync-critical02.f90
@kiranchandramohan Please check this PR. For me,
|
const auto pair{GetContext().scope.try_emplace( | ||
name.source, Attrs{}, UnknownDetails{})}; | ||
name.source, Attrs{}, ObjectEntityDetails{})}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set it back to UnknownDetails
it will work. I think for ObjectEntityDetails there are additional requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This solved the erring test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will @clementval @jeanPerier or @schweitzpgi know the importance of using the correct details here? AFAIU, for the name of critical sections we do not need ObjectEntityDetails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@klausler is it OK to use UnknownDetails here? This is for the name of an OpenMP Critical Section for which I think the ObjectEntityDetails do not apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnknownDetails
is mostly a place-holder intended to be replaced once more is known about a symbol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NimishMishra can you test @klausler's point, i.e what happens when we have a critical construct whose name matches a variable in the same scope?
The OpenMP standard says the following,
The names of critical constructs are global entities of the program. If a name conflicts with any other entity, the behavior of the program is unspecified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following works fine in fir-dev branch:
program sample
use omp_lib
integer :: foo, bar
bar = 0
!$omp critical (foo)
bar = bar + 1
!$omp end critical (foo)
end program sample
Running as flang-new -fc1 -fopenmp <FILENAME>.f90
gives no semantic problems at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also check conflicts with construct names (like a named do loop ) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked. The semantics phase doesn't complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thanks ! Could you add a regression test (I guess a symbol test would be the best (like these tests)) with both the variable name and construct name that are the same as the critical name just to be sure this property continues to hold true.
@sscalpone @schweitzpgi : Can you add @NimishMishra to this repo so that he can add reviewers and request reviewers? @NimishMishra works for Flang at AMD. |
I think we should not have merge commits in the PRs. Can you make this PR as a few commits,
|
@kiranchandramohan I have collapsed all into one commit. Please have a look |
Hi, I have just rebased fir-dev on LLVM 85bf221 from last week. You can update the PR as follow (assuming your branch is called my-branch):
Sorry for the inconvenience, I could not wait for every PR to get in and solve all new conflicts on my side, the rebase |
780cea1
to
b07c821
Compare
Can you add the two tests that were suggested? |
cc0da2f
to
04a4c55
Compare
If I run |
Gentle ping! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I guess this has to be now added to upstream llvm-project as well.
Sure. I'll upstream it |
I think it should not crash. But not sure whether it is an issue with unparsing. Does |
…struct name resolution
Cherry picking https://reviews.llvm.org/D110502 onto fir-dev branch