|
13 | 13 | #include "resolve-names-utils.h"
|
14 | 14 | #include "flang/Common/idioms.h"
|
15 | 15 | #include "flang/Evaluate/fold.h"
|
16 |
| -#include "flang/Evaluate/tools.h" |
17 | 16 | #include "flang/Evaluate/type.h"
|
18 | 17 | #include "flang/Parser/parse-tree-visitor.h"
|
19 | 18 | #include "flang/Parser/parse-tree.h"
|
@@ -267,7 +266,7 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
|
267 | 266 | Symbol::Flag::AccDevicePtr, Symbol::Flag::AccDeviceResident,
|
268 | 267 | Symbol::Flag::AccLink, Symbol::Flag::AccPresent};
|
269 | 268 |
|
270 |
| - void CheckAssociatedLoop(const parser::DoConstruct &); |
| 269 | + void CheckAssociatedLoopIndex(const parser::OpenACCLoopConstruct &); |
271 | 270 | void ResolveAccObjectList(const parser::AccObjectList &, Symbol::Flag);
|
272 | 271 | void ResolveAccObject(const parser::AccObject &, Symbol::Flag);
|
273 | 272 | Symbol *ResolveAcc(const parser::Name &, Symbol::Flag, Scope &);
|
@@ -883,8 +882,7 @@ bool AccAttributeVisitor::Pre(const parser::OpenACCLoopConstruct &x) {
|
883 | 882 | }
|
884 | 883 | ClearDataSharingAttributeObjects();
|
885 | 884 | SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
|
886 |
| - const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)}; |
887 |
| - CheckAssociatedLoop(*outer); |
| 885 | + CheckAssociatedLoopIndex(x); |
888 | 886 | return true;
|
889 | 887 | }
|
890 | 888 |
|
@@ -1089,10 +1087,6 @@ bool AccAttributeVisitor::Pre(const parser::OpenACCCombinedConstruct &x) {
|
1089 | 1087 | default:
|
1090 | 1088 | break;
|
1091 | 1089 | }
|
1092 |
| - const auto &clauseList{std::get<parser::AccClauseList>(beginBlockDir.t)}; |
1093 |
| - SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList)); |
1094 |
| - const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)}; |
1095 |
| - CheckAssociatedLoop(*outer); |
1096 | 1090 | ClearDataSharingAttributeObjects();
|
1097 | 1091 | return true;
|
1098 | 1092 | }
|
@@ -1224,8 +1218,8 @@ std::int64_t AccAttributeVisitor::GetAssociatedLoopLevelFromClauses(
|
1224 | 1218 | return 1; // default is outermost loop
|
1225 | 1219 | }
|
1226 | 1220 |
|
1227 |
| -void AccAttributeVisitor::CheckAssociatedLoop( |
1228 |
| - const parser::DoConstruct &outerDoConstruct) { |
| 1221 | +void AccAttributeVisitor::CheckAssociatedLoopIndex( |
| 1222 | + const parser::OpenACCLoopConstruct &x) { |
1229 | 1223 | std::int64_t level{GetContext().associatedLoopLevel};
|
1230 | 1224 | if (level <= 0) { // collapse value was negative or 0
|
1231 | 1225 | return;
|
@@ -1256,41 +1250,10 @@ void AccAttributeVisitor::CheckAssociatedLoop(
|
1256 | 1250 | return nullptr;
|
1257 | 1251 | };
|
1258 | 1252 |
|
1259 |
| - auto checkExprHasSymbols = [&](llvm::SmallVector<Symbol *> &ivs, |
1260 |
| - semantics::UnorderedSymbolSet &symbols) { |
1261 |
| - for (auto iv : ivs) { |
1262 |
| - if (symbols.count(*iv) != 0) { |
1263 |
| - context_.Say(GetContext().directiveSource, |
1264 |
| - "Trip count must be computable and invariant"_err_en_US); |
1265 |
| - } |
1266 |
| - } |
1267 |
| - }; |
1268 |
| - |
1269 |
| - Symbol::Flag flag; |
1270 |
| - llvm::SmallVector<Symbol *> ivs; |
1271 |
| - using Bounds = parser::LoopControl::Bounds; |
1272 |
| - for (const parser::DoConstruct *loop{&outerDoConstruct}; loop && level > 0;) { |
| 1253 | + const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)}; |
| 1254 | + for (const parser::DoConstruct *loop{&*outer}; loop && level > 0;) { |
1273 | 1255 | // Go through all nested loops to ensure index variable exists.
|
1274 |
| - if (const parser::Name * ivName{GetLoopIndex(*loop)}) { |
1275 |
| - if (auto *symbol{ResolveAcc(*ivName, flag, currScope())}) { |
1276 |
| - if (auto &control{loop->GetLoopControl()}) { |
1277 |
| - if (const Bounds * b{std::get_if<Bounds>(&control->u)}) { |
1278 |
| - if (auto lowerExpr{semantics::AnalyzeExpr(context_, b->lower)}) { |
1279 |
| - semantics::UnorderedSymbolSet lowerSyms = |
1280 |
| - evaluate::CollectSymbols(*lowerExpr); |
1281 |
| - checkExprHasSymbols(ivs, lowerSyms); |
1282 |
| - } |
1283 |
| - if (auto upperExpr{semantics::AnalyzeExpr(context_, b->upper)}) { |
1284 |
| - semantics::UnorderedSymbolSet upperSyms = |
1285 |
| - evaluate::CollectSymbols(*upperExpr); |
1286 |
| - checkExprHasSymbols(ivs, upperSyms); |
1287 |
| - } |
1288 |
| - } |
1289 |
| - } |
1290 |
| - ivs.push_back(symbol); |
1291 |
| - } |
1292 |
| - } |
1293 |
| - |
| 1256 | + GetLoopIndex(*loop); |
1294 | 1257 | const auto &block{std::get<parser::Block>(loop->t)};
|
1295 | 1258 | --level;
|
1296 | 1259 | loop = getNextDoConstruct(block, level);
|
|
0 commit comments