[flang-commits] [flang] [mlir] [mlir][flang][OpenMP] Select iterators per locator and allow multi-block regions (PR #227454)
via flang-commits
flang-commits at lists.llvm.org
Thu Oct 8 18:51:15 PDT 2026
================
@@ -1046,62 +1045,49 @@ bool ClauseProcessor::processAffinity(
.getResult();
};
- llvm::SmallVector<IteratorRange> iteratorRanges;
- llvm::SmallPtrSet<const Fortran::semantics::Symbol *, 4> ivSyms;
-
- auto &iteratorModifier =
- std::get<std::optional<omp::clause::Iterator>>(clause.t);
- collectIteratorIVs(clause, converter, stmtCtx, iteratorRanges, ivSyms);
+ auto iteratorRanges = lowerIteratorRanges(clause, converter, stmtCtx);
TodoLocators(clauseLocation, objects);
-
- for (const omp::Object &object : objects) {
+ for (const omp::Object &object : objects)
+ if (object.ref() && isVectorSubscript(*object.ref()))
+ TODO(clauseLocation, "vector subscript in AFFINITY clause");
+
+ auto genEntry = [&](const omp::Object &object,
+ lower::StatementContext &localStmtCtx) {
+ mlir::Value addr =
+ genAffinityAddr(converter, object, localStmtCtx, clauseLocation);
llvm::SmallVector<mlir::Value> bounds;
std::stringstream asFortran;
- if (iteratorModifier.has_value() &&
- hasIteratorIVReference(object, ivSyms)) {
+ fir::factory::AddrAndBoundsInfo info =
+ lower::gatherDataOperandAddrAndBounds<mlir::omp::MapBoundsOp,
+ mlir::omp::MapBoundsType>(
+ converter, builder, semaCtx, localStmtCtx, *object.sym(),
+ object.ref(), clauseLocation, asFortran, bounds,
+ treatIndexAsSection);
----------------
MattPD wrote:
The bounds helper can report an error and return empty or partial bounds. The caller then uses those bounds to create an affinity entry. For this source, `flang -c -O1 -fopenmp -fopenmp-version=52 repro.f90` prints `stride cannot be specified on an array section` but exits 0 and writes an object file:
```fortran
subroutine s(a, k)
integer :: a(8), k
!$omp task affinity(iterator(i=7:7): a(i:i:k))
!$omp end task
end
```
The [parent commit](https://github.com/llvm/llvm-project/commit/5655cabbd7b780c9b3bcfbbb07a619139990f06c) compiles the same source without that error.
With `integer :: a(2,8), k` and locator `a(1:2,i:i:k)`, this revision prints the same error and aborts at the bounds-size assertion in `computeBoundsSpan`.
OpenMP 5.2 prohibits an explicit stride expression in these locators. When bounds construction fails, could this path stop before using the resulting bounds and propagate the failure so the driver exits nonzero?
https://github.com/llvm/llvm-project/pull/227454
More information about the flang-commits
mailing list