[all-commits] [llvm/llvm-project] 44c6ae: [flang][OpenMP] Diagnose failed construct decompos...
Spencer Bryngelson via All-commits
all-commits at lists.llvm.org
Tue Aug 4 13:15:42 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 44c6aed9bd9b9cda993f4e93f2cbdb4fbba890d0
https://github.com/llvm/llvm-project/commit/44c6aed9bd9b9cda993f4e93f2cbdb4fbba890d0
Author: Spencer Bryngelson <sbryngelson at gmail.com>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
M flang/lib/Lower/OpenMP/Decomposer.cpp
Log Message:
-----------
[flang][OpenMP] Diagnose failed construct decomposition instead of falling through (#214012)
`buildConstructQueue` asserts that decomposition produced output:
```cpp
ConstructDecomposition decompose(modOp, semaCtx, eval, compound, clauses);
assert(!decompose.output.empty() && "Construct decomposition failed");
```
Release builds have no check, so the empty queue falls through to the
loop below and out to the
caller. That is undefined behaviour, and it is reachable — semantics
does not catch every
directive/clause combination that cannot be decomposed. The result is an
intermittent segfault
rather than a diagnostic.
#211430 is one way in: `allocate` is an OpenMP 5.0 clause, but most
directives declare it in
`OMP.td` without a minimum version, so semantics accepts it below 5.0
and decomposition then
correctly refuses it. flang defaults to OpenMP 3.1, so no unusual flags
are needed. The
intermittency is what made that report hard to pin down — 40 trials at
`-fopenmp-version=31`:
| | segfaults |
|---|---|
| ASLR on | 25/40 |
| ASLR off (`setarch -R`) | 0/40 |
which is an uninitialized read.
After this patch the same input fails deterministically with a located
diagnostic, 40/40:
```
error: loc("repro.f90":6:11): OpenMP construct decomposition failed: a clause on
'target teams distribute parallel do' cannot be applied to any of its leaf constructs
```
`genCrashDiag=false` so it exits non-zero without a backtrace, rather
than presenting as a compiler
crash.
This is a hardening fix for the lowering path and is independent of any
particular clause: it covers
every combination that decomposes empty. It does not make the `allocate`
case a *good* diagnostic —
that belongs in semantics, and #213980 is the separate change for it.
`check-flang` is clean (4808 tests). No test is added: the only in-tree
way to reach this path is
through the `OMP.td` gap that #213980 fixes, so a test here would encode
that gap as expected
behaviour and have to be removed when it lands. Happy to add one if
you'd prefer.
---
Parts of this change were written or audited with Claude Code. I have
reviewed all of it and take
full responsibility for the contribution. See
`llvm/docs/AIToolPolicy.md`.
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