-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[flang][OpenMP] Handle REQUIRES ADMO in lowering #144362
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 all commits
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 |
---|---|---|
|
@@ -1719,6 +1719,22 @@ void OmpStructureChecker::Leave(const parser::OpenMPDepobjConstruct &x) { | |
void OmpStructureChecker::Enter(const parser::OpenMPRequiresConstruct &x) { | ||
const auto &dir{std::get<parser::Verbatim>(x.t)}; | ||
PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_requires); | ||
|
||
if (visitedAtomicSource_.empty()) { | ||
return; | ||
} | ||
const auto &clauseList{std::get<parser::OmpClauseList>(x.t)}; | ||
for (const parser::OmpClause &clause : clauseList.v) { | ||
llvm::omp::Clause id{clause.Id()}; | ||
if (id == llvm::omp::Clause::OMPC_atomic_default_mem_order) { | ||
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. Is it allowed to have multiple REQUIRES directives with this clause? I imagine not, at least not in the same scope. 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. Good point. Yes, but they must have the same arguments. I'll add a check for that. 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. We actually already diagnose that. 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. Ahh sorry I should have checked - I just didn't see it in check-omp-structure and assumed. Thanks for having a look. |
||
parser::MessageFormattedText txt( | ||
"REQUIRES directive with '%s' clause found lexically after atomic operation without a memory order clause"_err_en_US, | ||
parser::ToUpperCaseLetters(llvm::omp::getOpenMPClauseName(id))); | ||
parser::Message message(clause.source, txt); | ||
message.Attach(visitedAtomicSource_, "Previous atomic construct"_en_US); | ||
context_.Say(std::move(message)); | ||
} | ||
} | ||
} | ||
|
||
void OmpStructureChecker::Leave(const parser::OpenMPRequiresConstruct &) { | ||
|
@@ -4028,6 +4044,9 @@ void OmpStructureChecker::CheckAtomicUpdate( | |
} | ||
|
||
void OmpStructureChecker::Enter(const parser::OpenMPAtomicConstruct &x) { | ||
if (visitedAtomicSource_.empty()) | ||
visitedAtomicSource_ = x.source; | ||
|
||
// All of the following groups have the "exclusive" property, i.e. at | ||
// most one clause from each group is allowed. | ||
// The exclusivity-checking code should eventually be unified for 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.
Shouldn't these be caught by semantics and so be unreachable in lowering?
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.
There is a gap in the 5.2+ spec. The ATOMIC_DEFAULT_MEM_ORDER was allowed to have "acquire" and "release" as values, yet at the same time it didn't specify the behavior on a construct that doesn't allow these values.
The recommendation from @dreachem was to allow such cases, and simply not apply the ADMO to such constructs. This is effectively applying the default memory order (i.e. "relaxed") to them.