Skip to content

Commit c1211d5

Browse files
[IPO] Avoid repeated hash lookups (NFC) (llvm#129419)
1 parent 2bbb394 commit c1211d5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ class ProfiledCallGraph {
135135
ProfiledCallGraphNode *getEntryNode() { return &Root; }
136136

137137
void addProfiledFunction(FunctionId Name) {
138-
if (!ProfiledFunctions.count(Name)) {
138+
auto [It, Inserted] = ProfiledFunctions.try_emplace(Name);
139+
if (Inserted) {
139140
// Link to synthetic root to make sure every node is reachable
140141
// from root. This does not affect SCC order.
141142
// Store the pointer of the node because the map can be rehashed.
142143
auto &Node =
143144
ProfiledCallGraphNodeList.emplace_back(ProfiledCallGraphNode(Name));
144-
ProfiledFunctions[Name] = &Node;
145-
Root.Edges.emplace(&Root, ProfiledFunctions[Name], 0);
145+
It->second = &Node;
146+
Root.Edges.emplace(&Root, It->second, 0);
146147
}
147148
}
148149

0 commit comments

Comments
 (0)