diff options
author | Dehao Chen <dehao@google.com> | 2017-08-03 17:11:41 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2017-08-03 17:11:41 +0000 |
commit | b65c3a989fda1977369d5e617cac5cb3c2ac65a1 (patch) | |
tree | 72fe83bc51495623d42dffb53a245abe0e8d6f97 /lib/Analysis/ProfileSummaryInfo.cpp | |
parent | 5c7ada734838e784986e6e5b0e1ad78a79494822 (diff) |
Do not want to use BFI to get profile count for sample pgo
Summary: For SamplePGO, we already record the callsite count in the call instruction itself. So we do not want to use BFI to get profile count as it is less accurate.
Reviewers: tejohnson, davidxl, eraman
Reviewed By: eraman
Subscribers: sanjoy, llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D36025
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309964 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ProfileSummaryInfo.cpp')
-rw-r--r-- | lib/Analysis/ProfileSummaryInfo.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Analysis/ProfileSummaryInfo.cpp b/lib/Analysis/ProfileSummaryInfo.cpp index 12b86daa602..3c2e04de4a5 100644 --- a/lib/Analysis/ProfileSummaryInfo.cpp +++ b/lib/Analysis/ProfileSummaryInfo.cpp @@ -39,6 +39,12 @@ static cl::opt<int> ProfileSummaryCutoffCold( cl::desc("A count is cold if it is below the minimum count" " to reach this percentile of total counts.")); +static cl::opt<bool> AccurateSampleProfile( + "accurate-sample-profile", cl::Hidden, cl::init(false), + cl::desc("If the sample profile is accurate, we will mark all un-sampled " + "callsite as cold. Otherwise, treat un-sampled callsites as if " + "we have no profile.")); + // Find the minimum count to reach a desired percentile of counts. static uint64_t getMinCountForPercentile(SummaryEntryVector &DS, uint64_t Percentile) { @@ -78,10 +84,12 @@ ProfileSummaryInfo::getProfileCount(const Instruction *Inst, if (hasSampleProfile()) { // In sample PGO mode, check if there is a profile metadata on the // instruction. If it is present, determine hotness solely based on that, - // since the sampled entry count may not be accurate. + // since the sampled entry count may not be accurate. If there is no + // annotated on the instruction, return None. uint64_t TotalCount; if (Inst->extractProfTotalWeight(TotalCount)) return TotalCount; + return None; } if (BFI) return BFI->getBlockProfileCount(Inst->getParent()); @@ -199,7 +207,15 @@ bool ProfileSummaryInfo::isHotCallSite(const CallSite &CS, bool ProfileSummaryInfo::isColdCallSite(const CallSite &CS, BlockFrequencyInfo *BFI) { auto C = getProfileCount(CS.getInstruction(), BFI); - return C && isColdCount(*C); + if (C) + return isColdCount(*C); + + // In SamplePGO, if the caller has been sampled, and there is no profile + // annotatedon the callsite, we consider the callsite as cold. + // If there is no profile for the caller, and we know the profile is + // accurate, we consider the callsite as cold. + return (hasSampleProfile() && + (CS.getCaller()->getEntryCount() || AccurateSampleProfile)); } INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", |