Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down