[all-commits] [llvm/llvm-project] 770a27: [flang][OpenMP] Lower iterator modifiers in map an...

Chi-Chun, Chen via All-commits all-commits at lists.llvm.org
Fri Sep 25 12:46:23 PDT 2026


  Branch: refs/heads/users/cchen/flang_openmp_motion_map_iterator
  Home:   https://github.com/llvm/llvm-project
  Commit: 770a2732b47c10ba67834409efc82084dc1c98cf
      https://github.com/llvm/llvm-project/commit/770a2732b47c10ba67834409efc82084dc1c98cf
  Author: Chi-Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M flang/include/flang/Utils/OpenMP.h
    M flang/lib/Lower/OpenMP/ClauseProcessor.cpp
    M flang/lib/Lower/OpenMP/ClauseProcessor.h
    M flang/lib/Lower/OpenMP/Clauses.cpp
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    M flang/lib/Lower/OpenMP/Utils.cpp
    M flang/lib/Lower/OpenMP/Utils.h
    M flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
    M flang/lib/Semantics/check-omp-structure.cpp
    M flang/lib/Utils/OpenMP.cpp
    A flang/test/Lower/OpenMP/Todo/declare-mapper-iterator-unsupported.f90
    R flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90
    R flang/test/Lower/OpenMP/Todo/from-iterator-modifier.f90
    A flang/test/Lower/OpenMP/Todo/map-iterator-ref-attach.f90
    A flang/test/Lower/OpenMP/Todo/map-motion-iterator-unsupported-locators.f90
    A flang/test/Lower/OpenMP/Todo/target-map-iterator.f90
    R flang/test/Lower/OpenMP/Todo/to-iterator-modifier.f90
    A flang/test/Lower/OpenMP/declare-mapper-iterator.f90
    M flang/test/Lower/OpenMP/depend-iterator.f90
    A flang/test/Lower/OpenMP/iterator-ranges.f90
    A flang/test/Lower/OpenMP/motion-iterator.f90
    M flang/test/Lower/OpenMP/task-affinity.f90
    M flang/test/Semantics/OpenMP/target-enter-data-temp-descriptor-omp61.f90
    M flang/test/Semantics/OpenMP/target-enter-data-temp-descriptor.f90
    M flang/test/Transforms/omp-map-info-finalization.fir
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Dialect/OpenMP/invalid.mlir
    A mlir/test/Dialect/OpenMP/iterator-ranges.mlir
    M mlir/test/Target/LLVMIR/openmp-iterator.mlir
    M mlir/test/Target/LLVMIR/openmp-taskwait-depend.mlir

  Log Message:
  -----------
  [flang][OpenMP] Lower iterator modifiers in map and motion clauses

Add iterator lowering for `target data`, `target enter/exit data`,
`target update`, and map clauses inside `declare mapper`.

For example:

```fortran
!$omp target update to(iterator(i=1:n): a(i), b)
```

Conceptually, this becomes:

```text
entries = omp.iterator(i = 1 through n) {
  yield map_info(base = a, bounds = element i)
}
target_update(iterated_maps = entries, ordinary_maps = [b])
```

Keeping the array base and expressing selections through bounds lets the
same approach handle array elements, sections, and descriptor-backed arrays.

Each locator is expanded only over the iterators that appear in it:

```text
iterator(i=1:n, j=1:m): a(i), b(j), c(i,j)
                        |     |      |
                        i     j    i x j
```

Iterator ranges use the same canonical loop semantics throughout lowering:

```text
trip_count = canonicalTripCount(lower, upper, step, inclusive)

if any trip_count == 0:
    result = []
    skip iterator region
```

These rules preserve source behavior in edge cases. Fortran ranges include
the endpoint, so lowering marks them inclusive instead of dropping the last
entry. A range such as `5:1:1` is empty and yields no entries instead of being
mistaken for a large range. Bounds and reconstructed iterator values keep
their source integer width, preventing `INTEGER(16)` values from being
truncated.

Supports explicit and default mappers, including mapper declarations
imported from other modules.

This PR stacked on top of #197047 and #197752.

This patch is part of feature work for #188061.

Assisted with codex.


  Commit: e872e608483816849d61a3e2595fc9c7a0bcc092
      https://github.com/llvm/llvm-project/commit/e872e608483816849d61a3e2595fc9c7a0bcc092
  Author: Chi-Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/openmp-iterator.mlir

  Log Message:
  -----------
  Widen iterator trip-count arithmetic


Compare: https://github.com/llvm/llvm-project/compare/8acbf4966cdf...e872e6084838

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list