[flang-commits] [flang] [mlir] [Flang][OpenMP] Don't generate code for unreachable target regions. (PR #178937)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Thu Feb 5 03:47:46 PST 2026
abidh wrote:
> 2. MLIR has `DominanceInfo::isReachableFromEntry()`. When combined with `SCCPPass` you could get what you want for free
>
> ```
> pm.addPass(createSCCPPass()); // Fold constant branches
> pm.addPass(createCanonicalizerPass()); // Clean up
> pm.addPass(flangomp::createMarkUnreachableTargetsPass()); // now use DominanceInfo::isReachableFromEntry
> ```
Thanks @bhandarkar-pranav. That is very useful comment. I have changed code now so that block reachability is checked using DominanceInfo::isReachableFromEntry. I found that it works even without running SCCP and Canonicalizer pass first so I have not added them in the pipeline. Also running those 2 passes would fail almost all the existing OpenMP tests. The churn was too much so I thought I would avoid them if we don't really need them.
https://github.com/llvm/llvm-project/pull/178937
More information about the flang-commits
mailing list