[llvm] [IPO] Avoid repeated hash lookups (NFC) (PR #129987)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 21:48:24 PST 2025


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

None

>From 144b83a8a19c1dde04bf320c08c1d47c9723751c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 5 Mar 2025 09:04:57 -0800
Subject: [PATCH] [IPO] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index c440638884322..2a3df722d29c5 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -134,7 +134,8 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
   unsigned ArgNo = 0, NewArgNo = 0;
   for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
        ++I, ++ArgNo) {
-    if (!ArgsToPromote.count(&*I)) {
+    auto It = ArgsToPromote.find(&*I);
+    if (It == ArgsToPromote.end()) {
       // Unchanged argument
       Params.push_back(I->getType());
       ArgAttrVec.push_back(PAL.getParamAttrs(ArgNo));
@@ -150,7 +151,7 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
 
       NewArgIndices.push_back((unsigned)-1);
     } else {
-      const auto &ArgParts = ArgsToPromote.find(&*I)->second;
+      const auto &ArgParts = It->second;
       for (const auto &Pair : ArgParts) {
         Params.push_back(Pair.second.Ty);
         ArgAttrVec.push_back(AttributeSet());



More information about the llvm-commits mailing list