-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Flang][OpenMP] Fix default firstprivatization miscategorization of mod file symbols #157009
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
[Flang][OpenMP] Fix default firstprivatization miscategorization of mod file symbols #157009
Conversation
…od file symbols In at least certain cases, notably when equivalence is used (at least for the example this showed up as a problem in) we currently miscategorize symbols as firstprivate when they may not be, as they can throw a false positive when a yse symbol from a mod file is picked up. The fix to this is to chase up the appropriate symbol to access the correct details.
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-flang-openmp Author: None (agozillon) ChangesIn at least certain cases, notably when equivalence is used (at least for the example this showed up as a problem in) we currently miscategorize symbols as firstprivate when they may not be, as they can throw a false positive when a use symbol from a mod file is picked up. The fix to this is to chase up the appropriate symbol to access the correct details. Full diff: https://github.com/llvm/llvm-project/pull/157009.diff 1 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index a08e764ecf936..2eca768766887 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2517,14 +2517,15 @@ static bool IsTargetCaptureImplicitlyFirstprivatizeable(const Symbol &symbol,
return false;
};
- if (checkSymbol(symbol)) {
- const auto *hostAssoc{symbol.detailsIf<HostAssocDetails>()};
- if (hostAssoc) {
- return checkSymbol(hostAssoc->symbol());
- }
- return true;
- }
- return false;
+ return common::visit(
+ common::visitors{
+ [&](const UseDetails &x) -> bool { return checkSymbol(x.symbol()); },
+ [&](const HostAssocDetails &x) -> bool {
+ return checkSymbol(x.symbol());
+ },
+ [&](const auto &) -> bool { return checkSymbol(symbol); },
+ },
+ symbol.details());
}
void OmpAttributeVisitor::CreateImplicitSymbols(const Symbol *symbol) {
|
If there's any suggestions for how best to create a test for this I'd be happy to add one, wasn't sure if there was a precedence in the Flang MLIR lit tests for having a two file test where one emits a mod file to use in the actual test file! Otherwise, if there's any other similar edge cases like this that people know that might be possible I'd be happy to see about testing and addressing those! Still a lot of details about symbols that I'm missing :-) |
Does the issue only occur when the module and its use are in separate files? In any case, a test or example would be good to help understand the issue. |
Thank you I'll give them a try! I believe it only happens when it's in another file, it's when the symbol we initially "capture" emits something along the lines of "Use of symbol from *.mod" |
Added a test that hopefully helps shed some light on things a bit better, thank you very much for the pointer to the example test! :-) |
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, thanks for adding a test.
Thank you very much for the help and the review! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/30328 Here is the relevant piece of the build log for the reference
|
In at least certain cases, notably when equivalence is used (at least for the example this showed up as a problem in) we currently miscategorize symbols as firstprivate when they may not be, as they can throw a false positive when a use symbol from a mod file is picked up.
The fix to this is to chase up the appropriate symbol to access the correct details.