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

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 11:08:28 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;
   };
----------------
aengelke wrote:

Yeah, that's what I tried to say in the last sentence -- it would be good to change how predecessors are stored (I have some ideas here) to permit memset-initialization.

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


More information about the llvm-commits mailing list