[llvm] [GenericDomTreeConstruction] Speed up Semi-NCA construction (PR #207474)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 08:31:27 PDT 2026


================
@@ -277,13 +293,14 @@ template <typename DomTreeT> struct SemiNCAInfo {
   // This function requires DFS to be run before calling it.
   void runSemiNCA() {
     const unsigned NextDFSNum(NumToNode.size());
-    SmallVector<InfoRec *, 8> NumToInfo = {nullptr};
+    SmallVector<InfoRec *, 32> NumToInfo = {nullptr};
     NumToInfo.reserve(NextDFSNum);
-    // Initialize IDoms to spanning tree parents.
+    // Immediate dominators in DFS-number space, initialized to spanning tree
+    // parents.
+    SmallVector<unsigned, 32> IDoms(NextDFSNum);
----------------
MaskRay wrote:

Switched to resize_for_overwrite. Index 0 is an unused sentinel.

As a future follow-up we probably should try 0-based indexing
https://maskray.me/blog/2020-12-11-dominator-tree

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


More information about the llvm-commits mailing list