[all-commits] [llvm/llvm-project] b0c2dc: [flang][PFT-to-MLIR] allocate missing body blocks ...
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Wed Jul 22 00:55:32 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b0c2dc0cf8f8de2fd2f0306deea0c5fcd07282da
https://github.com/llvm/llvm-project/commit/b0c2dc0cf8f8de2fd2f0306deea0c5fcd07282da
Author: Kareem Ergawy <kergawy at nvidia.com>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M flang/include/flang/Lower/DirectivesCommon.h
A flang/test/Lower/OpenMP/wsloop-computed-goto.f90
A flang/test/Lower/OpenMP/wsloop-select-case.f90
Log Message:
-----------
[flang][PFT-to-MLIR] allocate missing body blocks in `createEmptyRegionBlocks` (#210950)
Problem
-------
Under -mmlir --wrap-unstructured-constructs-in-execute-region, branch
lowering hit a null Evaluation::block for body statements inside an
OpenMP loop. genMultiwayBranch tripped
Bridge.cpp: Assertion `block && "missing multiway branch block"' failed
and genFIR(SelectCaseStmt) tripped
Bridge.cpp: Assertion `e->block && "missing CaseStmt block"' failed
The wrap machinery decides an unstructured DO/IF is wrappable and stops
propagating its isUnstructured flag to the enclosing OpenMPConstruct.
The OMP construct's isUnstructured stays false, so the top-level
createEmptyBlocks treats it as a structured directive with nested
evaluations — it allocates only the OMP construct's first-nested block
and does not recurse into the DO body. Then OMP loop lowering takes
over the body via createEmptyRegionBlocks, which was written to
*re-parent* pre-existing blocks into its region and silently skipped
evals whose .block was still null. Body targets (e.g. label 17's
ContinueStmt, or a SelectCase's CaseStmts) therefore had no block when
the consumer read evalOfLabel(...).block, tripping the asserts.
Solution
--------
Restore the invariant that consumers of eval.block can trust it at
lowering time. In createEmptyRegionBlocks (DirectivesCommon.h), when an
eval has isNewBlock but no .block, create one in the current region
alongside the existing re-parenting path. The OMP lowering path then
finds pre-allocated blocks for the whole body — matching the state that
existed before the wrap feature changed isUnstructured propagation —
without any lazy-allocation logic at consumer sites.
Co-authored-by: Claude Opus 4.7 <noreply at anthropic.com>
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