[llvm] e87b1b1 - [CSSPGO] Use callsite sample counts to annotate indirect call sites.
Hongtao Yu via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 14:52:44 PST 2021
Author: Hongtao Yu
Date: 2021-02-18T14:52:34-08:00
New Revision: e87b1b1d4e789d2350a07873998c992c08152ee6
URL: https://github.com/llvm/llvm-project/commit/e87b1b1d4e789d2350a07873998c992c08152ee6
DIFF: https://github.com/llvm/llvm-project/commit/e87b1b1d4e789d2350a07873998c992c08152ee6.diff
LOG: [CSSPGO] Use callsite sample counts to annotate indirect call sites.
With CSSPGO all indirect call targets are counted torwards the original indirect call site in the profile, including both inlined and non-inlined targets. Therefore no need to look for callee entry counts. This also fixes the issue where callee entry count doesn't match callsite count due to the nature of CS sampling.
I'm also cleaning up the orginal code that called `findIndirectCallFunctionSamples` just to compute the sum, the return value of which was disgarded.
Reviewed By: wmi, wenlei
Differential Revision: https://reviews.llvm.org/D96990
Added:
Modified:
llvm/lib/Transforms/IPO/SampleProfile.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 528a7166db55..fff6a7cfa457 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1248,8 +1248,19 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) {
}
SmallVector<InstrProfValueData, 2> SortedCallTargets =
GetSortedValueDataFromCallTargets(T.get());
- uint64_t Sum;
- findIndirectCallFunctionSamples(I, Sum);
+ uint64_t Sum = 0;
+ for (const auto &C : T.get())
+ Sum += C.second;
+ // With CSSPGO all indirect call targets are counted torwards the
+ // original indirect call site in the profile, including both
+ // inlined and non-inlined targets.
+ if (!FunctionSamples::ProfileIsCS) {
+ if (const FunctionSamplesMap *M =
+ FS->findFunctionSamplesMapAt(CallSite)) {
+ for (const auto &NameFS : *M)
+ Sum += NameFS.second.getEntrySamples();
+ }
+ }
annotateValueSite(*I.getParent()->getParent()->getParent(), I,
SortedCallTargets, Sum, IPVK_IndirectCallTarget,
SortedCallTargets.size());
More information about the llvm-commits
mailing list