diff options
author | Hongtao Yu <hoy@fb.com> | 2022-05-09 13:23:59 -0700 |
---|---|---|
committer | Hongtao Yu <hoy@fb.com> | 2022-05-13 09:19:32 -0700 |
commit | 1662cfa4be33edd94ab71f8aa83676eb8b378f4a (patch) | |
tree | 91ed7ce96ab21766a105475dbd8707989d54218a /llvm/lib/ProfileData/SampleProf.cpp | |
parent | af5e09b7d9646861863807d8d70e4e672505544e (diff) | |
download | llvm-1662cfa4be33edd94ab71f8aa83676eb8b378f4a.zip llvm-1662cfa4be33edd94ab71f8aa83676eb8b378f4a.tar.gz llvm-1662cfa4be33edd94ab71f8aa83676eb8b378f4a.tar.bz2 |
[CSSPGO][CSProfileConverter] Remove call target samples when including callee samples into caller.
When a flat CS profile is converted to a nested profile, the call target samples for inlined callee contexts are left over in the callsite target map. This could cause indirect call promotion to function improperly. One issue is that the inlined callsites are treated with double amount of samples. The other is the inlined callsites are reconsidered for subsequent PGO ICP.
I'm fixing this by excluding call targets from the callsite for inlined targets. While fixing this I found that callsite target sum and the number of body samples for that callsite could be mismatched. {D122609} has an explanation and a fix for that on llvm-profgen side. For now I'm tolerating it in this change.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D125266
Diffstat (limited to 'llvm/lib/ProfileData/SampleProf.cpp')
-rw-r--r-- | llvm/lib/ProfileData/SampleProf.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp index 9862605..5e32543 100644 --- a/llvm/lib/ProfileData/SampleProf.cpp +++ b/llvm/lib/ProfileData/SampleProf.cpp @@ -518,6 +518,12 @@ void CSProfileConverter::convertProfiles(CSProfileConverter::FrameNode &Node) { auto &SamplesMap = NodeProfile->functionSamplesAt(ChildNode.CallSiteLoc); SamplesMap.emplace(OrigChildContext.getName().str(), *ChildProfile); NodeProfile->addTotalSamples(ChildProfile->getTotalSamples()); + // Remove the corresponding body sample for the callsite and update the + // total weight. + auto Count = NodeProfile->removeCalledTargetAndBodySample( + ChildNode.CallSiteLoc.LineOffset, ChildNode.CallSiteLoc.Discriminator, + OrigChildContext.getName()); + NodeProfile->removeTotalSamples(Count); } // Separate child profile to be a standalone profile, if the current parent |