[llvm] a42ac55 - [IPO] Avoid repeated hash lookups (NFC) (#135750)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 17 23:03:28 PDT 2025


Author: Kazu Hirata
Date: 2025-04-17T23:03:25-07:00
New Revision: a42ac55a79db071e7e6da385213c5486d4b14986

URL: https://github.com/llvm/llvm-project/commit/a42ac55a79db071e7e6da385213c5486d4b14986
DIFF: https://github.com/llvm/llvm-project/commit/a42ac55a79db071e7e6da385213c5486d4b14986.diff

LOG: [IPO] Avoid repeated hash lookups (NFC) (#135750)

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 561c01cb01f82..257a7de6935d7 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -4099,14 +4099,14 @@ bool CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::assignFunctions() {
         assert(FuncClonesToCallMap.count(FuncClone));
         std::map<CallInfo, CallInfo> &CallMap = FuncClonesToCallMap[FuncClone];
         CallInfo CallClone(Call);
-        if (CallMap.count(Call))
-          CallClone = CallMap[Call];
+        if (auto It = CallMap.find(Call); It != CallMap.end())
+          CallClone = It->second;
         CallsiteClone->setCall(CallClone);
         // Need to do the same for all matching calls.
         for (auto &MatchingCall : Node->MatchingCalls) {
           CallInfo CallClone(MatchingCall);
-          if (CallMap.count(MatchingCall))
-            CallClone = CallMap[MatchingCall];
+          if (auto It = CallMap.find(MatchingCall); It != CallMap.end())
+            CallClone = It->second;
           // Updates the call in the list.
           MatchingCall = CallClone;
         }


        


More information about the llvm-commits mailing list