[clang] [flang] [llvm] [clang][flang][OpenMP] Fix context selector matching and scoring (PR #224431)

via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 3 03:13:45 PDT 2026


================
@@ -1,93 +1,169 @@
-! Test lowering of OpenMP metadirective with user={condition()} selectors.
+! Test lowering of OpenMP metadirective with dynamic user={condition()}
+! selectors.
 
-! RUN: %flang_fc1 -fopenmp -emit-hlfir -fopenmp-version=50 %s -o - | FileCheck %s
 ! RUN: %flang_fc1 -fopenmp -emit-hlfir -fopenmp-version=51 %s -o - | FileCheck %s
----------------
MattPD wrote:

`metadirective-user-static.f90` still runs with `-fopenmp-version=50`, but `metadirective-user.f90` now runs only under OpenMP 5.1 and 5.2. The remaining OpenMP 5.0 metadirective tests use static conditions, so they do not exercise the runtime subset check and ranking changed by this PR.

Could a dynamic case valid under OpenMP 5.0 restore that coverage? You can compile the following input with `flang -fc1 -fopenmp -fopenmp-version=50 -emit-hlfir -module-dir /tmp repro.f90 -o -`:

```fortran
subroutine v50_candidate_order(flag)
  logical :: flag
  !$omp metadirective &
  !$omp& when(implementation={vendor(score(100): llvm)}: taskyield) &
  !$omp& when(implementation={vendor(score(1): llvm)}, &
  !$omp& user={condition(score(20): flag)}: barrier) &
  !$omp& when(user={condition(score(10): .true.)}: taskwait)
end subroutine
subroutine v50_default(flag)
  logical :: flag
  !$omp metadirective when(user={condition(flag)}: barrier) default(taskwait)
end subroutine
```

At 1850727, `v50_candidate_order` emits conditional BARRIER/TASKWAIT. At the merge base, it emits TASKYIELD unconditionally. The separate `v50_default` case exercises the older `default(taskwait)` fallback. Restoring the OpenMP 5.0 RUN line for the whole current file would not work, because its newer cases use syntax rejected under 5.0.

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


More information about the cfe-commits mailing list