llvm-project
13cd7a29 - [flang][OpenACC] Generalize cross-region GOTO exit handling for all ACC region ops (#187613)

Commit
36 days ago
[flang][OpenACC] Generalize cross-region GOTO exit handling for all ACC region ops (#187613) When a `GoTo` inside an ACC region (`acc.loop`, `acc.data`, `acc.parallel`, etc.) targets a label outside that region, the lowering generated an illegal cross-region `cf.br`. This caused MLIR verification failures or stack overflows in `runRegionDCE`'s recursive `propagateLiveness`. This patch addresses the issue with a generalized approach: - Add `genOpenACCRegionExitBranch` helper that detects cross-region branches from any ACC region op and generates the appropriate terminator (`acc.yield` for compute/loop ops, `acc.terminator` for data ops). The helper verifies that `parentOp` is an ACC operation, so it does not interfere with branches inside `scf.execute_region` or other non-ACC regions. - In `genBranch`, when a cross-region exit from an ACC region is detected, store a unique exit ID into a selector variable and generate the region terminator. After the ACC op, a jump table dispatches to the correct target based on the selector. This correctly handles GOTOs that skip intermediate code between the loop end and the target label. - Emit a TODO diagnostic for GOTOs that cross multiple nested ACC region boundaries. - Fix `acc.data` creation when the construct has no data clauses but contains unstructured control flow: skip the early return in `genACCDataOp` so the `acc.data` region is created and blocks are properly managed.
Author
Parents
Loading