[llvm] [DominanceFrontier] Support multiple root nodes for post-dom (PR #181257)
Andrei Elovikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 09:15:55 PST 2026
================
@@ -74,14 +74,16 @@ void DominanceFrontierBase<BlockT, IsPostDom>::dump() const {
#endif
template <class BlockT, bool IsPostDom>
-void DominanceFrontierBase<BlockT, IsPostDom>::calculate(
- const DomTreeT &DT, const DomTreeNodeT *Node) {
- BlockT *BB = Node->getBlock();
+void DominanceFrontierBase<BlockT, IsPostDom>::calculate(const DomTreeT &DT) {
+ // NOTE: RootNode might be virtual for `IsPostDom == true`.
+ const DomTreeNodeT *RootNode = DT.getRootNode();
+ BlockT *BB = RootNode->getBlock();
std::vector<DFCalculateWorkObject<BlockT>> workList;
SmallPtrSet<BlockT *, 32> visited;
- workList.push_back(DFCalculateWorkObject<BlockT>(BB, nullptr, Node, nullptr));
+ workList.push_back(
+ DFCalculateWorkObject<BlockT>(BB, nullptr, RootNode, nullptr));
----------------
eas wrote:
I prefer having the virtual root, because that means the algorithm itself remains the same. If we start initializing the worklist differently then we kinda need to prove the math is still correct (however simple that may be).
https://github.com/llvm/llvm-project/pull/181257
More information about the llvm-commits
mailing list