[flang-commits] [flang] [mlir] [mlir][OpenMP] Add iterator support to map/motion clause (PR #197047)

via flang-commits flang-commits at lists.llvm.org
Fri Jun 5 12:54:23 PDT 2026


================
@@ -311,6 +311,7 @@ class FunctionFilteringPass
       targetOp.setDependKindsAttr(nullptr);
       targetOp.getDependIteratedMutable().clear();
       targetOp.setDependIteratedKindsAttr(nullptr);
+      targetOp.getMapIteratedMutable().clear();
----------------
chichunchen wrote:

There is also a source-value issue in Flang-style lowering. The iterator result models the yielded map-entry handle, but the target body may need the original FIR reference or descriptor as the isolated region argument:

```mlir
  %it = omp.iterator(...) {
    %map = omp.map.info
             var_ptr(%a : !fir.ref<!fir.array<16xi32>>, !fir.array<16xi32>)
             bounds(%bounds) -> !llvm.ptr
    omp.yield(%map : !llvm.ptr)
  } -> !omp.iterated<!llvm.ptr>

  omp.target
    map_iterated(%it : !omp.iterated<!llvm.ptr>)
    map_iterated_captures(%a -> %a.dev : !fir.ref<!fir.array<16xi32>>) {
    hlfir.declare %a.dev ...
    omp.terminator
  }
```

With only `%it -> %a.dev`, the `omp.target` operation would not explicitly state which outside SSA value is made available as `%a.dev`. That source value would have to be recovered by looking through the iterator body and selecting the `var_ptr` / `var_ptr_ptr` operand of the yielded `omp.map.info`. That is possible, but it makes the target-region argument binding implicit and couples the target capture semantics to the internal shape of the iterator body.

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


More information about the flang-commits mailing list