[llvm-branch-commits] [flang] [mlir] [mlir][flang][OpenMP] Select iterators per locator and allow multi-block regions (PR #227454)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 7 15:58:03 PDT 2026
================
@@ -1046,62 +1044,46 @@ 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) {
+ 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);
+ hlfir::Entity entity{info.addr};
+ mlir::Value len =
+ object.ref() && object.ref()->Rank() == 0
+ ? genElementSizeInBytes(builder, clauseLocation,
+ builder.getDataLayout(), entity)
+ : genAffinityLen(builder, clauseLocation,
+ builder.getDataLayout(), entity, bounds);
+ return makeAffinityEntry(builder, clauseLocation, entryTy, addr, len);
+ };
+
+ for (const omp::Object &object : objects) {
+ llvm::SmallVector<IteratorRange> objectRanges =
+ getIteratorRangesForObject(object, iteratorRanges);
+ if (!objectRanges.empty()) {
mlir::Value iterHandle = buildIteratorOp(
- converter, clauseLocation, iterTy, iteratorRanges,
+ converter, clauseLocation, iterTy, objectRanges,
[&](fir::FirOpBuilder &builder, mlir::Location loc,
llvm::ArrayRef<mlir::Value> /*ivs*/) -> mlir::Value {
lower::StatementContext iterStmtCtx;
-
- if (std::optional<llvm::SmallVector<mlir::Value>>
- loweredIndices = getIteratorElementIndices(
- converter, object, iterStmtCtx, loc)) {
- const Fortran::semantics::Symbol *sym = object.sym();
- assert(sym && "expected symbol for iterator object");
- fir::factory::AddrAndBoundsInfo info =
- Fortran::lower::getDataOperandBaseAddr(
- converter, builder, *sym, loc,
- /*unwrapFirBox=*/false);
- hlfir::Entity entity{info.addr};
- mlir::Value iteratedAddr = genIteratorCoordinate(
- converter, entity, *loweredIndices, loc);
- mlir::Value len = genElementSizeInBytes(
- builder, loc, builder.getDataLayout(), entity);
- return makeAffinityEntry(builder, loc, entryTy,
- iteratedAddr, len);
- }
-
- TODO(loc, "object type not supported by iterator modifier");
+ return genEntry(object, iterStmtCtx);
----------------
chichunchen wrote:
Fixed. AFFINITY now reports vector subscripts as not yet implemented, with or without an iterator.
https://github.com/llvm/llvm-project/pull/227454
More information about the llvm-branch-commits
mailing list