[llvm] [IDF] Use BitVectors indexed by DFS number for visited sets (NFC). (PR #227832)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 05:48:45 PDT 2026
================
@@ -144,18 +145,20 @@ void IDFCalculatorBase<NodeTy, IsPostDom>::calculate(
DT.updateDFSNumbers();
+ // The DFS in-numbers are unique and dense in [0, number of nodes), with the
+ // root's DFS out-number being the number of nodes. Use them to index the
+ // visited sets.
+ const DomTreeNodeBase<NodeTy> *RootNode = DT.getRootNode();
+ unsigned NumNodes = RootNode ? RootNode->getDFSNumOut() : 0;
+
SmallVector<DomTreeNodeBase<NodeTy> *, 32> Worklist;
- SmallPtrSet<DomTreeNodeBase<NodeTy> *, 16> VisitedPQ;
- SmallPtrSet<DomTreeNodeBase<NodeTy> *, 16> VisitedWorklist;
- if (useLiveIn) {
- VisitedPQ.reserve(LiveInBlocks->size());
- VisitedWorklist.reserve(LiveInBlocks->size());
- }
+ BitVector VisitedPQ(NumNodes);
+ BitVector VisitedWorklist(NumNodes);
----------------
fhahn wrote:
Updated to use `SmallVector<bool, 32>`, although it does not really move things much https://llvm-compile-time-tracker.com/compare.php?from=d9cf0304e74379f3b1da8405822dcc6726f39ebb&to=becc578a7c17f5b06ff4333ad1f334ffe2e85751&stat=instructions:u
https://github.com/llvm/llvm-project/pull/227832
More information about the llvm-commits
mailing list