[all-commits] [llvm/llvm-project] 1cd0cd: [flang][OpenMP] Support lowering of metadirective ...

Chi-Chun, Chen via All-commits all-commits at lists.llvm.org
Wed May 27 13:38:16 PDT 2026


  Branch: refs/heads/users/cchen/flang-metadirective-dynamic-user-cond
  Home:   https://github.com/llvm/llvm-project
  Commit: 1cd0cd86d1f2c987d75020101a87f44bd2e4bde3
      https://github.com/llvm/llvm-project/commit/1cd0cd86d1f2c987d75020101a87f44bd2e4bde3
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    R flang/test/Lower/OpenMP/Todo/metadirective-dynamic.f90
    M flang/test/Lower/OpenMP/metadirective-user.f90

  Log Message:
  -----------
  [flang][OpenMP] Support lowering of metadirective (part 2)

Lower non-constant user={condition(expr)} selectors in metadirectives
to a fir.if/else chain.

Only statically applicable when-clauses participate in dynamic
selection. Dynamic conditions are evaluated at runtime in declaration
order, with the best static match, an explicit otherwise/default
clause, or implicit nothing as the final fallback.

This patch is part of the feature work for #188820.

Assisted with copilot and GPT-5.4


  Commit: 070de8b96dbd057280d61d29c2a40fbcc52273c5
      https://github.com/llvm/llvm-project/commit/070de8b96dbd057280d61d29c2a40fbcc52273c5
  Author: chichunchen <chichunchen844 at gmail.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    M flang/test/Lower/OpenMP/metadirective-user.f90

  Log Message:
  -----------
  Fix dynamic metadirective candidate selection

- Use one scored candidate path for static and dynamic metadirective variants.
- Dynamic user conditions are statically filtered and scored using their
  non-user traits, then guarded at runtime with fir.if.
- Keeps construct/device/implementation traits enforced for dynamic
  candidates and lets higher-scored static candidates beat lower-scored dynamic
  candidates.
- Add regressions for construct mismatch, score ordering, and
  implicit-nothing tie-breaking.


  Commit: 982dd0b81a6cba79b60662a4966a0d2af4a42aa0
      https://github.com/llvm/llvm-project/commit/982dd0b81a6cba79b60662a4966a0d2af4a42aa0
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    M flang/test/Lower/OpenMP/metadirective-user.f90

  Log Message:
  -----------
  Clarify dynamic metadirective selection lowering

Explain that statically applicable variants are ranked before dynamic
user conditions. When a dynamic condition is selected, it is lowered to a
runtime branch whose else region continues selection among the remaining
candidates.

Add a begin/end variant test that includes clauses, and tighten checks
for the empty `nothing` fallback.


  Commit: 2cf62320b1d0d7cd87c3c0e4449d0b664d7ae458
      https://github.com/llvm/llvm-project/commit/2cf62320b1d0d7cd87c3c0e4449d0b664d7ae458
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    M flang/lib/Lower/OpenMP/Utils.cpp
    M flang/lib/Lower/OpenMP/Utils.h
    M flang/test/Lower/OpenMP/metadirective-user.f90

  Log Message:
  -----------
  Place dynamic condition cleanups before branching

A dynamic user condition can create expression temporaries before the
selected variant is lowered. For example, a metadirective condition
such as:

  when(user={condition(getbool("hello"))}: barrier)

passes a character literal through an associated temporary. That
temporary belongs to evaluating the condition, so it must be cleaned
up before lowering enters the generated fir.if that selects between
variants.

Finalize the statement context after evaluating the condition and
before creating the branch. Keep the condition expression and source
location together as DynamicUserCondition, use that source for
generated operations, and add a regression for the temporary-producing
condition case.


Compare: https://github.com/llvm/llvm-project/compare/81e5925d3258...2cf62320b1d0

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