[llvm] [IPO] Avoid repeated map lookups (NFC) (PR #128462)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 23 21:19:59 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/128462

None

>From 15c09b9db0d259f6814bc398fd861717ed71ec07 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 23 Feb 2025 09:01:55 -0800
Subject: [PATCH] [IPO] Avoid repeated map lookups (NFC)

---
 llvm/lib/Transforms/IPO/SampleContextTracker.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
index f878e3e591a05..270ca56d04823 100644
--- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
+++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
@@ -71,8 +71,8 @@ SampleContextTracker::moveContextSamples(ContextTrieNode &ToNodeParent,
   std::map<uint64_t, ContextTrieNode> &AllChildContext =
       ToNodeParent.getAllChildContext();
   assert(!AllChildContext.count(Hash) && "Node to remove must exist");
-  AllChildContext[Hash] = NodeToMove;
   ContextTrieNode &NewNode = AllChildContext[Hash];
+  NewNode = NodeToMove;
   NewNode.setCallSiteLoc(CallSite);
 
   // Walk through nodes in the moved the subtree, and update



More information about the llvm-commits mailing list