[llvm] [ADT] Use SmallVector in df_iterator. NFC (PR #225787)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 07:07:08 PDT 2026


https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/225787

Helps with compile time. The small size of 8 was chosen to match ReversePostOrderTraversal.

https://llvm-compile-time-tracker.com/compare.php?from=5bb2e21c30de31871dd01279c13abcfa2c06e75f&to=3f3c5680cae30aa33f6988ee8b326b71f5195577&stat=instructions:u


>From 70aac0f1d6fc71079d87737d85a7b6e75b6763fe Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Wed, 23 Sep 2026 14:28:23 +0100
Subject: [PATCH] [ADT] Use SmallVector in df_iterator. NFC

Helps with compile time. The small size of 8 was chosen to match ReversePostOrderTraversal.

https://llvm-compile-time-tracker.com/compare.php?from=5bb2e21c30de31871dd01279c13abcfa2c06e75f&to=3f3c5680cae30aa33f6988ee8b326b71f5195577&stat=instructions:u
---
 llvm/include/llvm/ADT/DepthFirstIterator.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h
index d2d3da3cd6fdfb..97febd9777cc1f 100644
--- a/llvm/include/llvm/ADT/DepthFirstIterator.h
+++ b/llvm/include/llvm/ADT/DepthFirstIterator.h
@@ -36,12 +36,12 @@
 
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/iterator_range.h"
 #include <iterator>
 #include <optional>
 #include <type_traits>
 #include <utility>
-#include <vector>
 
 namespace llvm {
 
@@ -104,7 +104,7 @@ class df_iterator : public df_iterator_storage<SetType, ExtStorage> {
   using StackElement = std::pair<NodeRef, std::optional<ChildItTy>>;
 
   // VisitStack - Used to maintain the ordering.  Top = current block
-  std::vector<StackElement> VisitStack;
+  SmallVector<StackElement, 8> VisitStack;
 
   inline df_iterator(NodeRef Node) {
     this->Visited.insert(Node);



More information about the llvm-commits mailing list