[llvm] [CFG] Add shortcut if CycleInfo is available (PR #188928)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 02:18:02 PDT 2026
================
@@ -235,10 +235,21 @@ static bool isReachableImpl(SmallVectorImpl<BasicBlock *> &Worklist,
const Cycle *OuterC = nullptr;
if (CI) {
OuterC = CI->getTopLevelParentCycle(BB);
- if (CyclesWithHoles.count(OuterC))
- OuterC = nullptr;
- else if (StopCycles.contains(OuterC))
- return true;
+ if (OuterC) {
+ if (CyclesWithHoles.count(OuterC))
+ OuterC = nullptr;
+ else if (StopCycles.contains(OuterC))
+ return true;
+ } else {
+ // If BB is not part of a cycle, then it can't reach any block that
+ // dominates it. An exception is if the block is unreachable, as all
+ // reachable blocks dominate an unreachable block.
+ if (DT && DT->isReachableFromEntry(BB) &&
+ llvm::all_of(StopSet, [&](const BasicBlock *StopBB) {
+ return DT->dominates(StopBB, BB);
+ }))
+ continue;
----------------
ro-i wrote:
doesn't `continue` mess with the `Limit` counter?
https://github.com/llvm/llvm-project/pull/188928
More information about the llvm-commits
mailing list