[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:52:36 PST 2026


================
@@ -120,65 +113,134 @@ class ReachabilityGraph {
     assert(I != LoopEnterers.end());
     return I->second;
   }
+  unsigned getSCCId(MachineBasicBlock *MBB) const {
+    return SccId[getIndex(MBB)];
----------------
aheejin wrote:

I think this can be a problem..? getSCCId can be called on BBs outside the region. In `calculate()`,
```cpp
    for (auto *Looper : Loopers) {
      unsigned LoopScc = getSCCId(Looper);
      for (auto *Pred : Looper->predecessors()) {
        if (getSCCId(Pred) != LoopScc) {
```

In `makeSingleEntryLoop()`,
```cpp
  for (auto *Pred : AllPreds) {
    for (auto *Entry : Pred->successors()) {
      if (!Entries.count(Entry))
        continue;
      if (Graph.getSCCId(Entry) == Graph.getSCCId(Pred)) {
        InLoop.insert(Pred);
        break;
      }
```

Loop entries are guaranteed to be in the region, but are predecessors? What if a region is itself a loop so `Pred` doesn't belong to it? Maybe we should exclude those conditions at the call sites of `getSCCId`.

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


More information about the llvm-commits mailing list