[llvm] d1c1ab1 - [IPO] Avoid repeated hash lookups (NFC) (#129654)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 4 07:28:52 PST 2025


Author: Kazu Hirata
Date: 2025-03-04T07:28:48-08:00
New Revision: d1c1ab100a496ada2208a92c37938c3ca8666e24

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

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

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
index 9ee92c38ffa23..fc18c596d9462 100644
--- a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
+++ b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
@@ -150,13 +150,13 @@ class ProfiledCallGraph {
 private:
   void addProfiledCall(FunctionId CallerName, FunctionId CalleeName,
                        uint64_t Weight = 0) {
-    assert(ProfiledFunctions.count(CallerName));
     auto CalleeIt = ProfiledFunctions.find(CalleeName);
     if (CalleeIt == ProfiledFunctions.end())
       return;
-    ProfiledCallGraphEdge Edge(ProfiledFunctions[CallerName],
-                               CalleeIt->second, Weight);
-    auto &Edges = ProfiledFunctions[CallerName]->Edges;
+    auto CallerIt = ProfiledFunctions.find(CallerName);
+    assert(CallerIt != ProfiledFunctions.end());
+    ProfiledCallGraphEdge Edge(CallerIt->second, CalleeIt->second, Weight);
+    auto &Edges = CallerIt->second->Edges;
     auto [EdgeIt, Inserted] = Edges.insert(Edge);
     if (!Inserted) {
       // Accumulate weight to the existing edge.


        


More information about the llvm-commits mailing list