llvm-project
56adb6e7 - [OpenMP][clang][flang] Compare tied context selectors with each other (#233905)

Commit
6 days ago
[OpenMP][clang][flang] Compare tied context selectors with each other (#233905) When several context selectors tie for the highest score, a selector that is a strict subset of another tied selector loses, and otherwise the first one wins. getBestVariantMatchForContext only compared each candidate with the current best, which isn't enough because that comparison isn't transitive: ``` #pragma omp metadirective \ when(user={condition(1)}, \ implementation={vendor(score(4): llvm)}: taskyield) \ when(device={kind(cpu)}, \ implementation={vendor(score(3): llvm)}: taskwait) \ when(user={condition(1)}, device={kind(host)}, \ implementation={vendor(score(3): llvm)}: barrier) ``` All three score 5 on the host. The first is a strict subset of the third, so TASKWAIT should be selected. The scan kept the first over the second, replaced it with the third, and never compared the third with the second, so it selected BARRIER. This patch collects all variants with the highest score, drops any that is a strict subset of another of them, and selects the first one left. As before, a strict subset only loses to a variant with the same score. This affects metadirective and declare variant selection in Clang and Flang. Flang reruns the selection for each runtime alternative, so comparing every tied variant with all the others can slow compilation when there are many. The tie-break first checks the supersets it has already found, so tied variants that share a few supersets need only a few comparisons each. The header now documents the tie-break. Fixes #233893. Assisted-by: GitHub Copilot (Claude Opus 5.5)
Author
Parents
Loading