[llvm] Reapply "[DomTreeUpdater] Move critical edge splitting code to updater" (PR #119547)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 22:16:06 PST 2024


paperchalice wrote:

I tried to modify post dominator tree via following code but failed with changing the root node.
```c++
for (const auto &[Idx, Edge] : enumerate(Edges)) {
    auto *FromNode = PDT->getNode(Edge.FromBB);

    // If FromBB is a non trivial root, then NewBB is the new non trivial root,
    // and NewBB post dominates FromBB.
    if (PDT->isVirtualRoot(FromNode->getIDom()) && !successors(Edge.FromBB).empty()) {
      auto *NewPDTNode = PDT->addNewBlock(Edge.NewBB, nullptr);
      PDT->changeImmediateDominator(FromNode, NewPDTNode);
      // PDT->setNewRoot(NewPDTNode); // Impossible...
    } else {
      // ToBB post dominates NewBB
      auto *NewPDTNode = PDT->addNewBlock(Edge.NewBB, Edge.ToBB);
      if (IsNewIPDom[Idx])
        PDT->changeImmediateDominator(FromNode, NewPDTNode);
    }
  }
```

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


More information about the llvm-commits mailing list