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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 20:57:59 PDT 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/131720.diff


1 Files Affected:

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


``````````diff
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 2a3df722d29c5..78115674f3cef 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -236,13 +236,13 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
     ArgNo = 0;
     for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
          ++I, ++AI, ++ArgNo) {
-      if (!ArgsToPromote.count(&*I)) {
+      auto ArgIt = ArgsToPromote.find(&*I);
+      if (ArgIt == ArgsToPromote.end()) {
         Args.push_back(*AI); // Unmodified argument
         ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));
       } else if (!I->use_empty()) {
         Value *V = *AI;
-        const auto &ArgParts = ArgsToPromote.find(&*I)->second;
-        for (const auto &Pair : ArgParts) {
+        for (const auto &Pair : ArgIt->second) {
           LoadInst *LI = IRB.CreateAlignedLoad(
               Pair.second.Ty,
               createByteGEP(IRB, DL, V, Pair.second.Ty, Pair.first),
@@ -266,7 +266,7 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
           ArgAttrVec.push_back(AttributeSet());
         }
       } else {
-        assert(ArgsToPromote.count(&*I) && I->use_empty());
+        assert(ArgIt != ArgsToPromote.end() && I->use_empty());
         DeadArgs.emplace_back(AI->get());
       }
     }

``````````

</details>


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


More information about the llvm-commits mailing list