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.