aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2025-09-24 12:00:54 +0200
committerMichael Kruse <llvm-project@meinersbur.de>2025-09-24 12:00:54 +0200
commitdd3f66d20a0001762f08f8b0942990fb548dad7e (patch)
tree7565200df0172894c371234095db6b08b8a1a118
parent375e948ee11d97e6659818687fcebdb049ea344d (diff)
parent493442453cbac2366aa89abde361f7badaad4948 (diff)
downloadllvm-users/meinersbur/mlir_loop-varnaming.zip
llvm-users/meinersbur/mlir_loop-varnaming.tar.gz
llvm-users/meinersbur/mlir_loop-varnaming.tar.bz2
Merge branch 'users/meinersbur/flang_loopnest-checks' into HEADusers/meinersbur/mlir_loop-varnaming
-rw-r--r--flang/lib/Semantics/resolve-directives.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 5f2c9f6..a010932 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1975,7 +1975,10 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
}
}
}
+
+ // Must be done before iv privatization
CheckPerfectNestAndRectangularLoop(x);
+
PrivatizeAssociatedLoopIndexAndCheckLoopLevel(x);
ordCollapseLevel = GetNumAffectedLoopsFromLoopConstruct(x) + 1;
return true;
@@ -2172,37 +2175,29 @@ void OmpAttributeVisitor::CollectNumAffectedLoopsFromClauses(
}
void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
- const parser::OpenMPLoopConstruct
- &x) { // GetAssociatedLoopLevelFromClauses(clauseList);
- auto &&dirContext = GetContext();
+ const parser::OpenMPLoopConstruct &x) {
+ auto &dirContext = GetContext();
std::int64_t dirDepth{dirContext.associatedLoopLevel};
if (dirDepth <= 0)
return;
- Symbol::Flag ivDSA;
- if (!llvm::omp::allSimdSet.test(GetContext().directive)) {
- ivDSA = Symbol::Flag::OmpPrivate;
- } else if (dirDepth == 1) {
- ivDSA = Symbol::Flag::OmpLinear;
- } else {
- ivDSA = Symbol::Flag::OmpLastPrivate;
- }
-
auto checkExprHasSymbols = [&](llvm::SmallVector<Symbol *> &ivs,
const parser::ScalarExpr *bound) {
if (ivs.empty())
return;
-
- if (auto boundExpr{semantics::AnalyzeExpr(context_, *bound)}) {
- semantics::UnorderedSymbolSet boundSyms =
- evaluate::CollectSymbols(*boundExpr);
- for (auto iv : ivs) {
- if (boundSyms.count(*iv) != 0) {
- // TODO: Point to occurence of iv in boundExpr, directiveSource as a
- // note
- context_.Say(dirContext.directiveSource,
- "Trip count must be computable and invariant"_err_en_US);
- }
+ auto boundExpr{semantics::AnalyzeExpr(context_, *bound)};
+ if (!boundExpr)
+ return;
+ semantics::UnorderedSymbolSet boundSyms =
+ evaluate::CollectSymbols(*boundExpr);
+ if (boundSyms.empty())
+ return;
+ for (Symbol *iv : ivs) {
+ if (boundSyms.count(*iv) != 0) {
+ // TODO: Point to occurence of iv in boundExpr, directiveSource as a
+ // note
+ context_.Say(dirContext.directiveSource,
+ "Trip count must be computable and invariant"_err_en_US);
}
}
};
@@ -2217,8 +2212,9 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(
innerMostNest)}) {
innerMostLoop = &(innerLoop->value());
- } else
+ } else {
break;
+ }
}
if (!innerMostNest)
@@ -2228,7 +2224,7 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
return;
llvm::SmallVector<Symbol *> ivs;
- int curLevel = 0;
+ int curLevel{0};
const parser::DoConstruct *loop{outer};
while (true) {
auto [iv, lb, ub, step] = GetLoopBounds(*loop);
@@ -2240,7 +2236,7 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
if (step)
checkExprHasSymbols(ivs, step);
if (iv) {
- if (auto *symbol{ResolveOmp(*iv, ivDSA, currScope())})
+ if (auto *symbol{currScope().FindSymbol(iv->source)})
ivs.push_back(symbol);
}