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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/ArgumentPromotion.cpp (+3-2) 


``````````diff
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());

``````````

</details>


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


More information about the llvm-commits mailing list