Skip to content

Commit d1c1ab1

Browse files
[IPO] Avoid repeated hash lookups (NFC) (#129654)
1 parent 1e6e845 commit d1c1ab1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ class ProfiledCallGraph {
150150
private:
151151
void addProfiledCall(FunctionId CallerName, FunctionId CalleeName,
152152
uint64_t Weight = 0) {
153-
assert(ProfiledFunctions.count(CallerName));
154153
auto CalleeIt = ProfiledFunctions.find(CalleeName);
155154
if (CalleeIt == ProfiledFunctions.end())
156155
return;
157-
ProfiledCallGraphEdge Edge(ProfiledFunctions[CallerName],
158-
CalleeIt->second, Weight);
159-
auto &Edges = ProfiledFunctions[CallerName]->Edges;
156+
auto CallerIt = ProfiledFunctions.find(CallerName);
157+
assert(CallerIt != ProfiledFunctions.end());
158+
ProfiledCallGraphEdge Edge(CallerIt->second, CalleeIt->second, Weight);
159+
auto &Edges = CallerIt->second->Edges;
160160
auto [EdgeIt, Inserted] = Edges.insert(Edge);
161161
if (!Inserted) {
162162
// Accumulate weight to the existing edge.

0 commit comments

Comments
 (0)