[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
Sat Oct 10 00:29:06 PDT 2026


================
@@ -1046,62 +1042,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() && evaluate::HasVectorSubscript(*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,
----------------
MattPD wrote:

Thanks for filing the follow-up issues. In [the issue about sections before the last part reference](https://github.com/llvm/llvm-project/issues/230587), `field(1)` already has a section-subscript list: [F2023 R919 and R921](https://j3-fortran.org/doc/year/24/24-007.pdf#page=154) allow scalar subscripts in that list. The OpenMP restriction quoted in the issue does not require a triplet in the final part reference.

Before this PR's iterator `AFFINITY` path calls `gatherDataOperandAddrAndBounds`, could it stop with a not-yet-implemented diagnostic for sections in earlier part references? The broader lowering repair could then remain follow-up work.

https://github.com/llvm/llvm-project/pull/227454


More information about the flang-commits mailing list