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

Chi-Chun, Chen via All-commits all-commits at lists.llvm.org
Mon Jun 1 14:01:01 PDT 2026


  Branch: refs/heads/users/cchen/flang-metadirective-dynamic-user-cond
  Home:   https://github.com/llvm/llvm-project
  Commit: 01836d01af741052096c413a1fddb09033efcd63
      https://github.com/llvm/llvm-project/commit/01836d01af741052096c413a1fddb09033efcd63
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-06-01 (Mon, 01 Jun 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: 83b49f999815d45e060c73d8e4310eafcd9c25d1
      https://github.com/llvm/llvm-project/commit/83b49f999815d45e060c73d8e4310eafcd9c25d1
  Author: chichunchen <chichunchen844 at gmail.com>
  Date:   2026-06-01 (Mon, 01 Jun 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: 25dd90f0fe9dce5156d6bf5a799b68d73d460702
      https://github.com/llvm/llvm-project/commit/25dd90f0fe9dce5156d6bf5a799b68d73d460702
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-06-01 (Mon, 01 Jun 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: 102f8728b6e5292476d0637c1cd8dcac173e3dd6
      https://github.com/llvm/llvm-project/commit/102f8728b6e5292476d0637c1cd8dcac173e3dd6
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-06-01 (Mon, 01 Jun 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.


  Commit: 47eee1d477169878dfec1ec5e50474cc175b0ae4
      https://github.com/llvm/llvm-project/commit/47eee1d477169878dfec1ec5e50474cc175b0ae4
  Author: Chi Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-06-01 (Mon, 01 Jun 2026)

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

  Log Message:
  -----------
  Preserve dynamic user condition scores for variant ranking

Dynamic user conditions are bypassed during static applicability
filtering, but their scores must still influence variant ordering.
Previously, the filtering VMI removed `user_condition_unknown`,
inadvertently dropping the score attached to
`user={condition(score(...): expr)}`.

We now preserves that score in the ranking VMI by transferring
any non-zero dynamic condition score onto `user_condition_true`. The
runtime condition remains separate and correctly lowers as a `fir.if`
guard for the selected variant.

Variant ordering now correctly prioritizes scored conditions over
lexically earlier unscored conditions or static fallbacks:

```
  if (high) barrier
  else if (low) taskyield
  else taskwait
```

Added a regression test to verify this ordering.


Compare: https://github.com/llvm/llvm-project/compare/b71f9efac9d1...47eee1d47716

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