[llvm] [WebAssembly] Replace Reachability with SCCs in Irreducible CFG Fixer (PR #179722)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 14 06:35:12 PST 2026


================
@@ -120,65 +113,138 @@ class ReachabilityGraph {
     assert(I != LoopEnterers.end());
     return I->second;
   }
+  unsigned getSCCId(MachineBasicBlock *MBB) const {
+    return SccId[getIndex(MBB)];
+  }
 
 private:
   MachineBasicBlock *Entry;
   const BlockSet &Blocks;
+  DenseMap<MachineBasicBlock *, unsigned> BlockIndex;
 
   BlockSet Loopers, LoopEntries;
   DenseMap<MachineBasicBlock *, BlockSet> LoopEnterers;
 
   bool inRegion(MachineBasicBlock *MBB) const { return Blocks.count(MBB); }
 
-  // Maps a block to all the other blocks it can reach.
-  DenseMap<MachineBasicBlock *, BlockSet> Reachable;
+  // Per-node adjacency in the region (excluding edges to Entry).
+  SmallVector<SmallVector<unsigned, 4>, 0> Succs;
+  SmallVector<bool, 0> SelfLoop;
+
+  // SCC = Strongly-connected component
+  // Map of an MBB's index (provided by `BlockIndex`) to it's assigned SCC
+  SmallVector<unsigned, 0> SccId; 
+  // The number of elements in each SCC
+  SmallVector<unsigned, 0> SccSize; 
----------------
aheejin wrote:

```suggestion
  SmallVector<unsigned, 0> SccId;
  // The number of elements in each SCC
  SmallVector<unsigned, 0> SccSize;
```

https://github.com/llvm/llvm-project/pull/179722


More information about the llvm-commits mailing list