Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 2, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h (+4-3)
diff --git a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
index 3e7cc74fcf23b..9ee92c38ffa23 100644
--- a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
+++ b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
@@ -135,14 +135,15 @@ class ProfiledCallGraph {
   ProfiledCallGraphNode *getEntryNode() { return &Root; }
   
   void addProfiledFunction(FunctionId Name) {
-    if (!ProfiledFunctions.count(Name)) {
+    auto [It, Inserted] = ProfiledFunctions.try_emplace(Name);
+    if (Inserted) {
       // Link to synthetic root to make sure every node is reachable
       // from root. This does not affect SCC order.
       // Store the pointer of the node because the map can be rehashed.
       auto &Node =
           ProfiledCallGraphNodeList.emplace_back(ProfiledCallGraphNode(Name));
-      ProfiledFunctions[Name] = &Node;
-      Root.Edges.emplace(&Root, ProfiledFunctions[Name], 0);
+      It->second = &Node;
+      Root.Edges.emplace(&Root, It->second, 0);
     }
   }
 

@kazutakahirata kazutakahirata merged commit c1211d5 into llvm:main Mar 2, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_IPO branch March 2, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants