[llvm-branch-commits] [flang] [flang][OpenMP] Support lowering of metadirective (part 2) (PR #194424)

Abid Qadeer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jun 1 04:42:45 PDT 2026


================
@@ -4720,13 +4724,20 @@ static void genMetadirective(lower::AbstractConverter &converter,
       auto [spec, isExplicit] = getDirectiveVariant(*whenClause);
 
       llvm::omp::VariantMatchInfo vmi;
-      const parser::ScalarExpr *dynCondExpr = nullptr;
-      makeVariantMatchInfo(vmi, ctxSel, semaCtx,
-                           converter.genLocation(clause.source), dynCondExpr);
-
-      if (dynCondExpr)
-        TODO(converter.genLocation(clause.source),
-             "dynamic user condition in METADIRECTIVE");
+      std::optional<DynamicUserCondition> dynamicCond = makeVariantMatchInfo(
+          vmi, ctxSel, semaCtx, converter.genLocation(clause.source));
+
+      // Ignore a runtime condition while testing static eligibility. If this
+      // variant is selected, the condition becomes a fir.if guard below.
+      if (dynamicCond) {
+        llvm::omp::VariantMatchInfo dynamicVMI = vmi;
+        dynamicVMI.RequiredTraits.reset(
+            unsigned(llvm::omp::TraitProperty::user_condition_unknown));
----------------
abidh wrote:

I wonder if `reset` call will break a test like this:
```
subroutine test_dynamic_score(flag)
  logical, intent(in) :: flag
  !$omp metadirective &
  !$omp & when(user={condition(score(1000): flag)}: barrier) &
  !$omp & when(device={kind(host)}: taskwait)
end subroutine
```
The dynamic condition has a higher explicit score. Should it be selected if `flag` is true over the static condition because of the higher score?

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


More information about the llvm-branch-commits mailing list