[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:46:49 PDT 2026


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

I agree that the explicit capture can look redundant in the simplest case where one iterator yields one `omp.map.info` for one mapped object, and the target region needs one block argument for that same object. However, I think `%it` and `%a` are different operands with different roles, so I would rather keep both relationships explicit.

`map_iterated` describes dynamic map entries produced by the iterator. For `omp.target`, we also need to describe the static SSA values made available as entry block arguments in the isolated target region. The iterator handle is not itself the source value for that target-region argument; the source value is the mapped
object, e.g. `%a`.

For example, the current representation allows multiple iterator-produced map entries sharing one target-region capture:

```mlir
%it0 = omp.iterator(...) {
  %m0 = omp.map.info
          var_ptr(%a : !llvm.ptr, i32)
          map_clauses(to)
          ...
  omp.yield(%m0 : !llvm.ptr)
} -> !omp.iterated<!llvm.ptr>

%it1 = omp.iterator(...) {
  %m1 = omp.map.info
          var_ptr(%a : !llvm.ptr, i32)
          map_clauses(from)
          ...
  omp.yield(%m1 : !llvm.ptr)
} -> !omp.iterated<!llvm.ptr>

omp.target
  map_iterated(%it0, %it1 : !omp.iterated<!llvm.ptr>, !omp.iterated<!llvm.ptr>)
  map_iterated_captures(%a -> %a.dev : !llvm.ptr) {
  // one target-region value for the shared base object %a
  omp.terminator
}
```

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


More information about the flang-commits mailing list