[llvm] [SelectionDAG] late init DeferredNodes (PR #123461)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 18 05:42:12 PST 2025


https://github.com/klensy created https://github.com/llvm/llvm-project/pull/123461

No need to init `SmallVector` (even stack allocated) if we can exit literally on next line.

>From b361d362a4149d73a75370ce67cdbfa721fd2dff Mon Sep 17 00:00:00 2001
From: klensy <nightouser at gmail.com>
Date: Sat, 18 Jan 2025 16:14:49 +0300
Subject: [PATCH] later init DeferredNodes

---
 llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 03899493847b39..49467ce0a54cd0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -916,10 +916,10 @@ END_TWO_BYTE_PACK()
                                    SmallVectorImpl<const SDNode *> &Worklist,
                                    unsigned int MaxSteps = 0,
                                    bool TopologicalPrune = false) {
-    SmallVector<const SDNode *, 8> DeferredNodes;
     if (Visited.count(N))
       return true;
 
+    SmallVector<const SDNode *, 8> DeferredNodes;
     // Node Id's are assigned in three places: As a topological
     // ordering (> 0), during legalization (results in values set to
     // 0), new nodes (set to -1). If N has a topolgical id then we



More information about the llvm-commits mailing list