[llvm] [WebAssembly] Replace Reachability with SCCs in Irreducible CFG Fixer (PR #179722)
Demetrius Kanios via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 22:12:50 PST 2026
QuantumSegfault wrote:
Looks like this has already been done in a different form elsewhere in LLVM!
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/SCCIterator.h
```cpp
/// This builds on the llvm/ADT/GraphTraits.h file to find the strongly
/// connected components (SCCs) of a graph in O(N+E) time using Tarjan's DFS
/// algorithm.
```
--------
I was looking for information on how to generate irreducible CFG, when I found a blog post about Cheerp, with a passing mention of _fixing_ irreducible control flow. https://labs.leaningtech.com/blog/control-flow#fix-the-irreducible-control-flow
So I took a look:
https://github.com/leaningtech/cheerp-compiler/blob/master/llvm/lib/CheerpUtils/FixIrreducibleControlFlow.cpp
--------
So do we want to try to use the existing SCCIterator instead of rolling our own implementation of the algorithm? Not sure if it'll be any better. Might end up being less optimized given our constraints/assumptions...but maybe we can have more confidence in it as it's been tested more thoroughly?
https://github.com/llvm/llvm-project/pull/179722
More information about the llvm-commits
mailing list