[llvm] [GenericDomTreeConstruction] Switch to 0-based DFS numbering (PR #207524)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 11:11:52 PDT 2026


================
@@ -59,19 +59,22 @@ template <typename DomTreeT> struct SemiNCAInfo {
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
   using GraphDiffT = GraphDiff<NodePtr, IsPostDom>;
 
+  // Marks a node that hasn't been visited by DFS.
+  static constexpr unsigned Unvisited = -1u;
+
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
-    unsigned DFSNum = 0;
+    unsigned DFSNum = Unvisited;
     unsigned Parent = 0;
     unsigned Semi = 0;
     unsigned Label = 0;
     NodePtr IDom = nullptr;
     SmallVector<unsigned, 4> ReverseChildren;
   };
----------------
MaskRay wrote:

Other functions are smaller. This patch makes `Dominators.cpp.o` 1149 bytes smaller in `.text`.

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


More information about the llvm-commits mailing list