[all-commits] [llvm/llvm-project] f99eba: [flang][OpenMP] Semantic checks for metadirective ...
Chi-Chun, Chen via All-commits
all-commits at lists.llvm.org
Mon Jul 6 11:24:51 PDT 2026
Branch: refs/heads/users/cchen/flang-metadirective-loop-checks
Home: https://github.com/llvm/llvm-project
Commit: f99eba8dae32864010703e4c2b1240ede51972dc
https://github.com/llvm/llvm-project/commit/f99eba8dae32864010703e4c2b1240ede51972dc
Author: Chi Chun, Chen <chichun.chen at hpe.com>
Date: 2026-07-06 (Mon, 06 Jul 2026)
Changed paths:
M flang/lib/Semantics/check-omp-structure.cpp
M flang/lib/Semantics/check-omp-structure.h
M flang/lib/Semantics/check-omp-variant.cpp
A flang/test/Semantics/OpenMP/metadirective-loop-applicability.f90
A flang/test/Semantics/OpenMP/metadirective-loop-nest.f90
A flang/test/Semantics/OpenMP/metadirective-loop-sequence.f90
Log Message:
-----------
[flang][OpenMP] Semantic checks for metadirective loop nests
A loop-associated metadirective variant (`do`, `simd`, ...) is only
resolved during lowering, so it is never checked as a loop construct
during semantic analysis. A malformed or non-canonical associated nest
therefore reaches lowering, which assumes a canonical nest.
This patch validates the nest that follows such a variant (the next
executable construct) during semantics, reusing the diagnostics of a real
loop-associated construct. Each applicable variant is checked against it:
* Canonical loop: the affected loop must be a canonical DO loop, so a
`DO WHILE`, a pre-6.0 `DO CONCURRENT`, or a `DO` without loop control
is rejected.
* Nest depth: `collapse(n)` and `ordered(n)` must not exceed the depth
of the associated loop nest.
* Rectangularity: loops that must be rectangular (e.g. under `tile`) may
not have bounds that depend on an outer loop's variable.
A loop-associated variant may also have no loop nest at all. This happens when
the metadirective ends the execution part or a non-loop construct follows it.
Such a variant is rejected like a bare loop directive with no associated loop.
Only variants that could be selected are checked: when a target is known, a
WHEN variant whose device or implementation selector cannot match it is
skipped (runtime `user` conditions never cause a skip).
Part of the feature work for #188820. Builds on top of
[#193664](https://github.com/llvm/llvm-project/issues/193664) and
[#194424](https://github.com/llvm/llvm-project/pull/194424).
Assisted with Copilot.
Commit: 1b90243706bbd9c5f43ce96b6f25da31f79a6ed0
https://github.com/llvm/llvm-project/commit/1b90243706bbd9c5f43ce96b6f25da31f79a6ed0
Author: Chi Chun, Chen <chichun.chen at hpe.com>
Date: 2026-07-06 (Mon, 06 Jul 2026)
Changed paths:
M flang/lib/Semantics/check-omp-variant.cpp
M flang/test/Semantics/OpenMP/metadirective-loop-applicability.f90
Log Message:
-----------
Skip loop checks for unselectable metadirective variants
A loop-associated METADIRECTIVE variant is only checked when it might be
selected on the compilation target. The static-applicability gate matched
device and implementation selectors, but it ignored two cases that make a
variant unselectable on any target:
- a user condition that folds to a compile-time false, and
- an unknown device or implementation property.
Such a variant still had its associated loop diagnosed even though it can
never be selected, so a valid program was rejected. Skip these variants in
the default match-all mode, where the impossible trait is decisive. The
match_any and match_none modes tolerate the trait, so they keep deferring
to context matching.
Assisted with Copilot.
Compare: https://github.com/llvm/llvm-project/compare/5652e59ad446...1b90243706bb
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