[flang-commits] [flang] 0244526 - [flang] Fixed restrictions checking for OpenACC loop-associated constructs.
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Jan 26 14:21:41 PST 2023
Author: Slava Zakharin
Date: 2023-01-26T14:20:57-08:00
New Revision: 02445263e2f533573a935c1bd502d848bbe6bb27
URL: https://github.com/llvm/llvm-project/commit/02445263e2f533573a935c1bd502d848bbe6bb27
DIFF: https://github.com/llvm/llvm-project/commit/02445263e2f533573a935c1bd502d848bbe6bb27.diff
LOG: [flang] Fixed restrictions checking for OpenACC loop-associated constructs.
CheckDoConcurrentClauseRestriction and CheckTileClauseRestriction expect
that the construct has associated DoConstruct, while it is not set
when the do-loop has no loop control. The change is to skip the clauses
checks, when the do-loop does not have the loop control.
An alternative fix would be to associate the DoConstruct even when
the do-loop has no loop control and let Check*ClauseRestriction run their
checks, but I am not sure if associating invalid DoConstruct is a good idea.
This fixes failure in Semantics/OpenACC/acc-canonicalization-validity.f90
reported in D142279.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D142652
Added:
Modified:
flang/lib/Semantics/canonicalize-acc.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/canonicalize-acc.cpp b/flang/lib/Semantics/canonicalize-acc.cpp
index 855f62f53ff8d..5afae172cfaa2 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -127,17 +127,17 @@ class CanonicalizationOfAcc {
nextIt = it;
if (++nextIt != block.end()) {
if (auto *doCons{parser::Unwrap<parser::DoConstruct>(*nextIt)}) {
- if (doCons->GetLoopControl()) {
- // move DoConstruct
- std::get<std::optional<parser::DoConstruct>>(x.t) =
- std::move(*doCons);
- nextIt = block.erase(nextIt);
- } else {
+ if (!doCons->GetLoopControl()) {
messages_.Say(dir.source,
"DO loop after the %s directive must have loop control"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
+ return;
}
+ // move DoConstruct
+ std::get<std::optional<parser::DoConstruct>>(x.t) = std::move(*doCons);
+ nextIt = block.erase(nextIt);
+
CheckDoConcurrentClauseRestriction<parser::OpenACCLoopConstruct,
parser::AccBeginLoopDirective>(x);
CheckTileClauseRestriction<parser::OpenACCLoopConstruct,
@@ -173,24 +173,23 @@ class CanonicalizationOfAcc {
nextIt = it;
if (++nextIt != block.end()) {
if (auto *doCons{parser::Unwrap<parser::DoConstruct>(*nextIt)}) {
- if (doCons->GetLoopControl()) {
- // move DoConstruct
- std::get<std::optional<parser::DoConstruct>>(x.t) =
- std::move(*doCons);
- nextIt = block.erase(nextIt);
- // try to match AccEndCombinedDirective
- if (nextIt != block.end()) {
- if (auto *endDir{
- parser::Unwrap<parser::AccEndCombinedDirective>(*nextIt)}) {
- std::get<std::optional<parser::AccEndCombinedDirective>>(x.t) =
- std::move(*endDir);
- block.erase(nextIt);
- }
- }
- } else {
+ if (!doCons->GetLoopControl()) {
messages_.Say(dir.source,
"DO loop after the %s directive must have loop control"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
+ return;
+ }
+ // move DoConstruct
+ std::get<std::optional<parser::DoConstruct>>(x.t) = std::move(*doCons);
+ nextIt = block.erase(nextIt);
+ // try to match AccEndCombinedDirective
+ if (nextIt != block.end()) {
+ if (auto *endDir{
+ parser::Unwrap<parser::AccEndCombinedDirective>(*nextIt)}) {
+ std::get<std::optional<parser::AccEndCombinedDirective>>(x.t) =
+ std::move(*endDir);
+ block.erase(nextIt);
+ }
}
CheckDoConcurrentClauseRestriction<parser::OpenACCCombinedConstruct,
More information about the flang-commits
mailing list