Skip to content

Commit 82956de

Browse files
committed
[SampleFDO] Fix a bug when appending function symbol into the Callees set of
Root node in ProfiledCallGraph. In ProfiledCallGraph::addProfiledFunction, to add a function symbol into the ProfiledCallGraph, currently an uninitialized ProfiledCallGraphNode node is created by ProfiledFunctions[Name] and inserted into Callees set of Root node before the node is initialized. The Callees set use ProfiledCallGraphNodeComparer as its comparator so the uninitialized ProfiledCallGraphNode may fail to be inserted into Callees set if it happens to contain a name in memory which has been inserted into the Callees set before. The problem will prevent some function symbols from being annotated with profiles and cause performance regression. The patch fixes the problem. Differential Revision: https://reviews.llvm.org/D101815
1 parent 0c2e2f8 commit 82956de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class ProfiledCallGraph {
8787
if (!ProfiledFunctions.count(Name)) {
8888
// Link to synthetic root to make sure every node is reachable
8989
// from root. This does not affect SCC order.
90-
Root.Callees.insert(&ProfiledFunctions[Name]);
9190
ProfiledFunctions[Name] = ProfiledCallGraphNode(Name);
91+
Root.Callees.insert(&ProfiledFunctions[Name]);
9292
}
9393
}
9494

0 commit comments

Comments
 (0)