[flang-commits] [flang] [llvm] [mlir] [flang][mlir][OpenMP] Support iterator modifier in declare mapper map clause (PR #215485)

Urvi Rav via flang-commits flang-commits at lists.llvm.org
Fri Sep 25 04:07:46 PDT 2026


================
@@ -3015,6 +3016,28 @@ class OpenMPIRBuilder {
     MapHasAttachPtrArrayTy HasAttachPtr;
     StructNonContiguousInfo NonContigInfo;
 
+    /// Represents a group of mapper sub-components produced by an `iterator`
+    /// modifier on a `declare mapper`'s map clause: the component count is
+    /// only known at runtime, so these are pushed one at a time via
+    /// __tgt_push_mapper_component from inside a generated loop, rather than
+    /// being added to the arrays above. Only consumed by
+    /// emitUserDefinedMapper; emitOffloadingArrays ignores this field.
+    struct DynamicSegment {
+      /// Runtime (i64) trip count for this segment.
+      Value *Count = nullptr;
+      /// Emits the code computing one iteration's (BasePointer, Pointer,
+      /// Size) triple, given the loop's linear induction variable (0-based,
+      /// i64). Owning (not function_ref): the callable is typically a
+      /// lambda temporary assigned in after construction, which would
+      /// otherwise dangle by the time this is invoked.
+      std::function<SmallVector<Value *, 3>(IRBuilderBase &, Value *)> GenEntry;
----------------
ravurvi20 wrote:

Done. `GenEntry` now returns Expected`<SmallVector<Value *, 3>>`. The caller in `emitUserDefinedMapper` checks the Expected and returns `takeError()` before indexing, and the MLIR-side lambda returns `PreviouslyReportedError` on `convertIteratorRegion` failure instead of an empty vector.

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


More information about the flang-commits mailing list