[flang-commits] [flang] [mlir] [Flang][OpenMP] Support iterator modifier in map and motion clauses (PR #197757)
via flang-commits
flang-commits at lists.llvm.org
Thu Oct 15 22:50:22 PDT 2026
================
@@ -1913,6 +1953,90 @@ void ClauseProcessor::processMapObjects(
}
}
+// Lower iterator-dependent locators to mapIterated and other locators to
+// mapVars.
+void ClauseProcessor::processMapObjectsWithIterator(
+ lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
+ const omp::ObjectList &objects,
+ llvm::ArrayRef<IteratorRange> iteratorRanges,
+ mlir::omp::ClauseMapFlags mapTypeBits,
+ std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
+ mlir::omp::MapClauseOps &result, llvm::SmallVectorImpl<Object> &mapObjects,
+ llvm::StringRef mapperIdNameRef, bool isMotionModifier,
+ llvm::omp::Directive directive) const {
+ if (iteratorRanges.empty()) {
+ processMapObjects(stmtCtx, clauseLocation, objects, mapTypeBits,
+ parentMemberIndices, result.mapVars, mapObjects,
+ mapperIdNameRef, isMotionModifier, directive);
+ return;
+ }
+
+ auto declareMapper = mlir::dyn_cast_if_present<mlir::omp::DeclareMapperOp>(
+ converter.getFirOpBuilder().getRegion().getParentOp());
+ auto isDeclareMapperVariable =
+ [&](const IteratorMapObjectAnalysis &analysis) {
+ if (!declareMapper || !analysis.rootSym)
+ return false;
+
+ mlir::Value rootAddress = converter.getSymbolAddress(*analysis.rootSym);
+ while (rootAddress) {
+ if (auto declare = rootAddress.getDefiningOp<hlfir::DeclareOp>()) {
+ rootAddress = declare.getMemref();
+ continue;
+ }
+ if (auto declare = rootAddress.getDefiningOp<fir::DeclareOp>()) {
+ rootAddress = declare.getMemref();
+ continue;
+ }
+ break;
+ }
+
+ return rootAddress == declareMapper.getRegion().front().getArgument(0);
+ };
+
+ constexpr mlir::omp::ClauseMapFlags unsupportedReferenceModifiers =
+ mlir::omp::ClauseMapFlags::ref_ptr | mlir::omp::ClauseMapFlags::ref_ptee |
+ mlir::omp::ClauseMapFlags::attach_always |
+ mlir::omp::ClauseMapFlags::attach_never |
+ mlir::omp::ClauseMapFlags::attach_auto;
+ bool hasUnsupportedReferenceModifier =
+ (mapTypeBits & unsupportedReferenceModifiers) !=
+ mlir::omp::ClauseMapFlags::none;
+
+ // Objects in an iterator-modified clause may independently reference
+ // iterator variables, so handle each object separately.
+ for (const omp::Object &object : objects) {
+ llvm::SmallVector<IteratorRange> objectRanges =
+ getIteratorRangesForObject(object, iteratorRanges);
+ if (!objectRanges.empty()) {
+ if (hasUnsupportedReferenceModifier)
+ TODO(clauseLocation,
+ "iterator modifier with reference or attach modifier");
+ IteratorMapObjectAnalysis analysis = analyzeIteratorMapObject(object);
+ bool isMapperVariable = isDeclareMapperVariable(analysis);
+ if (analysis.isDerivedTypeMember && !isMapperVariable)
+ TODO(clauseLocation, "iterator modifier with derived type member map");
+ if (declareMapper && analysis.rootSym && !isMapperVariable)
----------------
MattPD wrote:
Confirmed, both cases now get the not-yet-implemented diagnostic.
https://github.com/llvm/llvm-project/pull/197757
More information about the flang-commits
mailing list