[all-commits] [llvm/llvm-project] 775c4d: [clang][flang][OpenMP] Fix context selector matchi...
Chi-Chun, Chen via All-commits
all-commits at lists.llvm.org
Mon Sep 21 13:13:16 PDT 2026
Branch: refs/heads/users/cchen/openmp-variant-matching-scoring
Home: https://github.com/llvm/llvm-project
Commit: 775c4d558094ccc260851604f89e88bda2a65359
https://github.com/llvm/llvm-project/commit/775c4d558094ccc260851604f89e88bda2a65359
Author: Chi-Chun, Chen <chichun.chen at hpe.com>
Date: 2026-09-21 (Mon, 21 Sep 2026)
Changed paths:
M clang/include/clang/AST/OpenMPClause.h
M clang/include/clang/Serialization/ASTRecordWriter.h
M clang/lib/AST/OpenMPClause.cpp
M clang/lib/Parse/ParseOpenMP.cpp
M clang/lib/Sema/SemaOpenMP.cpp
M clang/lib/Serialization/ASTReader.cpp
M clang/lib/Serialization/ASTWriter.cpp
A clang/test/OpenMP/declare_variant_condition_identity_pch.c
M clang/test/OpenMP/declare_variant_device_kind_codegen.cpp
A clang/test/OpenMP/declare_variant_scoring.c
A clang/test/OpenMP/dispatch_variant_matching.c
M flang/include/flang/Lower/AbstractConverter.h
M flang/include/flang/Semantics/openmp-utils.h
M flang/lib/Lower/Bridge.cpp
M flang/lib/Lower/OpenMP/Atomic.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/Semantics/openmp-utils.cpp
M flang/test/Lower/OpenMP/declare-variant-construct.f90
A flang/test/Lower/OpenMP/declare-variant-source-context.f90
M flang/test/Lower/OpenMP/metadirective-device-kind.f90
M flang/test/Lower/OpenMP/metadirective-implementation.f90
A flang/test/Lower/OpenMP/metadirective-source-context.f90
A flang/test/Lower/OpenMP/metadirective-target-boundary.f90
A flang/test/Lower/OpenMP/metadirective-user-static.f90
M flang/test/Lower/OpenMP/metadirective-user.f90
A flang/test/Lower/OpenMP/variant-scoring-any-sections.f90
M llvm/include/llvm/Frontend/OpenMP/OMPContext.h
M llvm/lib/Frontend/OpenMP/OMPContext.cpp
M llvm/unittests/Frontend/OpenMPContextTest.cpp
Log Message:
-----------
[clang][flang][OpenMP] Fix context selector matching and scoring
Incorrect construct contexts and selector scoring can select the wrong
DECLARE VARIANT function or METADIRECTIVE replacement.
Build construct contexts in source order rather than emitted MLIR order:
Source: teams -> distribute -> parallel -> do
MLIR: teams -> parallel -> distribute -> do
Count executable constructs without selectable traits, omit informational
directives, and start the context at the innermost TARGET.
Compute device weights from the enclosing context depth, choose the
highest-scoring complete ordered construct match, and count each selector's
score once using arbitrary-width arithmetic.
Zero strict-subset scores before selecting the best applicable candidate.
For example, when both selectors match:
A: implementation={vendor(score(100): llvm)}
B: implementation={vendor(score(1): llvm)}, user={condition(1)}
A initially scores 101 and B scores 2. Since A is a strict subset of B,
A's final score is zero and B wins. Previously, subset checks applied
only to equal scores.
Preserve property and condition identity in subset comparisons, including
across Clang AST serialization. Keep Flang runtime and folded conditions
consistent: false conditions retain their identity, contribute no score
under match_any, and retain their score under match_none. Apply the same
ranking rules to implicit NOTHING replacements.
Add shared matcher unit tests and Clang/Flang regressions, including PCH
condition identity and static/runtime ranking.
This provides the shared matching and scoring prerequisite for #219014.
Assisted with Codex.
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