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

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


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Luke Lau (lukel97)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/225787.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/DepthFirstIterator.h (+2-2) 


``````````diff
diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h
index d2d3da3cd6fdf..97febd9777cc1 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);

``````````

</details>


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


More information about the llvm-commits mailing list