[llvm] r346005 - [ProfileSummary] Add options to override hot and cold count thresholds.
Easwaran Raman via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 2 10:39:31 PDT 2018
Author: eraman
Date: Fri Nov 2 10:39:31 2018
New Revision: 346005
URL: http://llvm.org/viewvc/llvm-project?rev=346005&view=rev
Log:
[ProfileSummary] Add options to override hot and cold count thresholds.
Summary:
The hot and cold count thresholds are derived from the summary, but for
debugging purposes it is convenient to provide the actual thresholds.
Reviewers: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D54040
Modified:
llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp
llvm/trunk/test/Analysis/ProfileSummary/basic.ll
Modified: llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp?rev=346005&r1=346004&r2=346005&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp Fri Nov 2 10:39:31 2018
@@ -51,6 +51,18 @@ static cl::opt<unsigned> ProfileSummaryH
" blocks required to reach the -profile-summary-cutoff-hot"
" percentile exceeds this count."));
+// The next two options override the counts derived from summary computation and
+// are useful for debugging purposes.
+static cl::opt<int> ProfileSummaryHotCount(
+ "profile-summary-hot-count", cl::ReallyHidden, cl::ZeroOrMore,
+ cl::desc("A fixed hot count that overrides the count derived from"
+ " profile-summary-cutoff-hot"));
+
+static cl::opt<int> ProfileSummaryColdCount(
+ "profile-summary-cold-count", cl::ReallyHidden, cl::ZeroOrMore,
+ cl::desc("A fixed cold count that overrides the count derived from"
+ " profile-summary-cutoff-cold"));
+
// Find the summary entry for a desired percentile of counts.
static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS,
uint64_t Percentile) {
@@ -198,9 +210,15 @@ void ProfileSummaryInfo::computeThreshol
auto &HotEntry =
getEntryForPercentile(DetailedSummary, ProfileSummaryCutoffHot);
HotCountThreshold = HotEntry.MinCount;
+ if (ProfileSummaryHotCount.getNumOccurrences() > 0)
+ HotCountThreshold = ProfileSummaryHotCount;
auto &ColdEntry =
getEntryForPercentile(DetailedSummary, ProfileSummaryCutoffCold);
ColdCountThreshold = ColdEntry.MinCount;
+ if (ProfileSummaryColdCount.getNumOccurrences() > 0)
+ ColdCountThreshold = ProfileSummaryColdCount;
+ assert(ColdCountThreshold <= HotCountThreshold &&
+ "Cold count threshold cannot exceed hot count threshold!");
HasHugeWorkingSetSize =
HotEntry.NumCounts > ProfileSummaryHugeWorkingSetSizeThreshold;
}
Modified: llvm/trunk/test/Analysis/ProfileSummary/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ProfileSummary/basic.ll?rev=346005&r1=346004&r2=346005&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ProfileSummary/basic.ll (original)
+++ llvm/trunk/test/Analysis/ProfileSummary/basic.ll Fri Nov 2 10:39:31 2018
@@ -1,19 +1,31 @@
; RUN: opt < %s -disable-output -passes=print-profile-summary -S 2>&1 | FileCheck %s
+; RUN: opt < %s -disable-output -profile-summary-hot-count=500 -passes=print-profile-summary -S 2>&1 | FileCheck %s -check-prefixes=OVERRIDE-HOT
+; RUN: opt < %s -disable-output -profile-summary-cold-count=0 -passes=print-profile-summary -S 2>&1 | FileCheck %s -check-prefixes=OVERRIDE-COLD
+; RUN: opt < %s -disable-output -profile-summary-cold-count=200 -profile-summary-hot-count=1000 -passes=print-profile-summary -S 2>&1 | FileCheck %s -check-prefixes=OVERRIDE-BOTH
define void @f1() !prof !20 {
; CHECK-LABEL: f1 :hot
+; OVERRIDE-HOT-LABEL: f1
+; OVERRIDE-COLD-LABEL: f1 :hot
+; OVERRIDE-BOTH-LABEL: f1
ret void
}
define void @f2() !prof !21 {
; CHECK-LABEL: f2 :cold
+; OVERRIDE-HOT-LABEL: f2 :cold
+; OVERRIDE-COLD-LABEL: f2
+; OVERRIDE-BOTH-LABEL: f2
ret void
}
define void @f3() !prof !22 {
; CHECK-LABEL: f3
+; OVERRIDE-HOT-LABEL: f3
+; OVERRIDE-COLD-LABEL: f3
+; OVERRIDE-BOTH-LABEL: f3
ret void
}
More information about the llvm-commits
mailing list