36 cl::desc(
"A count is hot if it exceeds the minimum count to" 37 " reach this percentile of total counts."));
41 cl::desc(
"A count is cold if it is below the minimum count" 42 " to reach this percentile of total counts."));
45 "profile-summary-huge-working-set-size-threshold",
cl::Hidden,
47 cl::desc(
"The code working set size is considered huge if the number of" 48 " blocks required to reach the -profile-summary-cutoff-hot" 49 " percentile exceeds this count."));
52 "profile-summary-large-working-set-size-threshold",
cl::Hidden,
54 cl::desc(
"The code working set size is considered large if the number of" 55 " blocks required to reach the -profile-summary-cutoff-hot" 56 " percentile exceeds this count."));
62 cl::desc(
"A fixed hot count that overrides the count derived from" 63 " profile-summary-cutoff-hot"));
67 cl::desc(
"A fixed cold count that overrides the count derived from" 68 " profile-summary-cutoff-cold"));
72 cl::desc(
"Specify the current profile is used as a partial profile."));
77 "If true, scale the working set size of the partial sample profile " 78 "by the partial profile ratio to reflect the size of the program " 82 "partial-sample-profile-working-set-size-scale-factor",
cl::Hidden,
84 cl::desc(
"The scale factor used to scale the working set size of the " 85 "partial sample profile along with the partial profile ratio. " 86 "This includes the factor of the profile counter per block " 87 "and the factor to scale the working set size to use the same " 88 "shared thresholds as PGO."));
115 assert((isa<CallInst>(Call) || isa<InvokeInst>(Call)) &&
116 "We can only get profile count for call/invoke instruction.");
123 if (Call.extractProfTotalWeight(TotalCount))
128 return BFI->getBlockProfileCount(Call.getParent(), AllowSynthetic);
138 auto FunctionCount =
F->getEntryCount();
142 return FunctionCount &&
isHotCount(FunctionCount.getCount());
154 if (
auto FunctionCount =
F->getEntryCount())
159 uint64_t TotalCallCount = 0;
160 for (
const auto &BB : *
F)
161 for (
const auto &
I : BB)
162 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
164 TotalCallCount += CallCount.getValue();
168 for (
const auto &BB : *
F)
183 if (
auto FunctionCount =
F->getEntryCount())
188 uint64_t TotalCallCount = 0;
189 for (
const auto &BB : *
F)
190 for (
const auto &
I : BB)
191 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
193 TotalCallCount += CallCount.getValue();
197 for (
const auto &BB : *
F)
205 return !
F.getEntryCount().hasValue();
208 template <
bool isHot>
209 bool ProfileSummaryInfo::isFunctionHotOrColdInCallGraphNthPercentile(
213 if (
auto FunctionCount =
F->getEntryCount()) {
222 uint64_t TotalCallCount = 0;
223 for (
const auto &BB : *
F)
224 for (
const auto &
I : BB)
225 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
227 TotalCallCount += CallCount.getValue();
233 for (
const auto &BB : *
F) {
245 return isFunctionHotOrColdInCallGraphNthPercentile<true>(
251 return isFunctionHotOrColdInCallGraphNthPercentile<false>(
265 auto FunctionCount =
F->getEntryCount();
269 return FunctionCount &&
isColdCount(FunctionCount.getCount());
273 void ProfileSummaryInfo::computeThresholds() {
274 auto &DetailedSummary = Summary->getDetailedSummary();
277 HotCountThreshold = HotEntry.MinCount;
282 ColdCountThreshold = ColdEntry.MinCount;
285 assert(ColdCountThreshold <= HotCountThreshold &&
286 "Cold count threshold cannot exceed hot count threshold!");
288 HasHugeWorkingSetSize =
290 HasLargeWorkingSetSize =
295 double PartialProfileRatio = Summary->getPartialProfileRatio();
296 uint64_t ScaledHotEntryNumCounts =
297 static_cast<uint64_t>(HotEntry.NumCounts * PartialProfileRatio *
299 HasHugeWorkingSetSize =
301 HasLargeWorkingSetSize =
311 if (iter != ThresholdCache.
end()) {
314 auto &DetailedSummary = Summary->getDetailedSummary();
323 return HasHugeWorkingSetSize && HasHugeWorkingSetSize.
getValue();
327 return HasLargeWorkingSetSize && HasLargeWorkingSetSize.
getValue();
331 return HotCountThreshold &&
C >= HotCountThreshold.
getValue();
335 return ColdCountThreshold &&
C <= ColdCountThreshold.
getValue();
338 template <
bool isHot>
339 bool ProfileSummaryInfo::isHotOrColdCountNthPercentile(
int PercentileCutoff,
363 return ColdCountThreshold ? ColdCountThreshold.
getValue() : 0;
368 auto Count =
BFI->getBlockProfileCount(BB);
374 auto Count =
BFI->getBlockProfileCount(BB);
378 template <
bool isHot>
379 bool ProfileSummaryInfo::isHotOrColdBlockNthPercentile(
381 auto Count =
BFI->getBlockProfileCount(BB);
422 "Profile summary info",
false,
true)
449 OS <<
"Functions in " << M.getName() <<
" with hot/cold annotations: \n";
453 OS <<
" :hot entry ";
455 OS <<
" :cold entry ";
void refresh()
If no summary is present, attempt to refresh.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module.
Function * getCaller()
Helper to get the caller (the parent function).
bool hasProfileSummary() const
Returns true if profile summary is available.
Analysis providing profile information.
static cl::opt< bool > PartialProfile("partial-profile", cl::Hidden, cl::init(false), cl::desc("Specify the current profile is used as a partial profile."))
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static cl::opt< unsigned > ProfileSummaryHugeWorkingSetSizeThreshold("profile-summary-huge-working-set-size-threshold", cl::Hidden, cl::init(15000), cl::ZeroOrMore, cl::desc("The code working set size is considered huge if the number of" " blocks required to reach the -profile-summary-cutoff-hot" " percentile exceeds this count."))
bool hasSampleProfile() const
Returns true if module M has sample profile.
Metadata * getProfileSummary(bool IsCS) const
Returns profile summary metadata.
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"))
Result run(Module &M, ModuleAnalysisManager &)
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
bool isHotCallSite(const CallBase &CB, BlockFrequencyInfo *BFI) const
Returns true if the call site CB is considered hot.
bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
bool isFunctionColdInCallGraph(const Function *F, BlockFrequencyInfo &BFI) const
Returns true if F contains only cold code.
bool isFunctionHotInCallGraph(const Function *F, BlockFrequencyInfo &BFI) const
Returns true if F contains hot code.
bool isFunctionColdInCallGraphNthPercentile(int PercentileCutoff, const Function *F, BlockFrequencyInfo &BFI) const
Returns true if F contains cold code with regard to a given cold percentile cutoff value.
static cl::opt< unsigned > CountThreshold("hexagon-cext-threshold", cl::init(3), cl::Hidden, cl::ZeroOrMore, cl::desc("Minimum number of extenders to trigger replacement"))
bool isHotCountNthPercentile(int PercentileCutoff, uint64_t C) const
Returns true if count C is considered hot with regard to a given hot percentile cutoff value.
static cl::opt< unsigned > PercentileCutoff("mfs-psi-cutoff", cl::desc("Percentile profile summary cutoff used to " "determine cold blocks. Unused if set to zero."), cl::init(999950), cl::Hidden)
bool isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI) const
Returns true if BasicBlock BB is considered cold.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
iterator find(const_arg_type_t< KeyT > Val)
bool isHotBlockNthPercentile(int PercentileCutoff, const BasicBlock *BB, BlockFrequencyInfo *BFI) const
Returns true if BasicBlock BB is considered hot with regard to a given hot percentile cutoff value.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
initializer< Ty > init(const Ty &Val)
bool hasLargeWorkingSetSize() const
Returns true if the working set size of the code is considered large.
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
bool isFunctionEntryHot(const Function *F) const
Returns true if F has hot function entry.
static cl::opt< double > PartialSampleProfileWorkingSetSizeScaleFactor("partial-sample-profile-working-set-size-scale-factor", cl::Hidden, cl::init(0.008), cl::desc("The scale factor used to scale the working set size of the " "partial sample profile along with the partial profile ratio. " "This includes the factor of the profile counter per block " "and the factor to scale the working set size to use the same " "shared thresholds as PGO."))
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", "Profile summary info", false, true) ProfileSummaryInfoWrapperPass
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
cl::opt< bool > ScalePartialSampleProfileWorkingSetSize("scale-partial-sample-profile-working-set-size", cl::Hidden, cl::init(true), cl::desc("If true, scale the working set size of the partial sample profile " "by the partial profile ratio to reflect the size of the program " "being compiled."))
bool isColdCallSite(const CallBase &CB, BlockFrequencyInfo *BFI) const
Returns true if call site CB is considered cold.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
bool hasHugeWorkingSetSize() const
Returns true if the working set size of the code is considered huge.
bool isFunctionHotInCallGraphNthPercentile(int PercentileCutoff, const Function *F, BlockFrequencyInfo &BFI) const
Returns true if F contains hot code with regard to a given hot percentile cutoff value.
uint64_t getOrCompColdCountThreshold() const
Returns ColdCountThreshold if set.
ImmutablePass class - This class is used to provide information that does not need to be run.
bool isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI) const
Returns true if BasicBlock BB is considered hot.
Module.h This file contains the declarations for the Module class.
constexpr const T & getValue() const LLVM_LVALUE_FUNCTION
void initializeProfileSummaryInfoWrapperPassPass(PassRegistry &)
bool hasPartialSampleProfile() const
Returns true if module M has partial-profile sample profile.
static ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
static cl::opt< int > ProfileSummaryCutoffHot("profile-summary-cutoff-hot", cl::Hidden, cl::init(990000), cl::ZeroOrMore, cl::desc("A count is hot if it exceeds the minimum count to" " reach this percentile of total counts."))
bool isColdBlockNthPercentile(int PercentileCutoff, const BasicBlock *BB, BlockFrequencyInfo *BFI) const
Returns true if BasicBlock BB is considered cold with regard to a given cold percentile cutoff value.
static cl::opt< unsigned > ProfileSummaryLargeWorkingSetSizeThreshold("profile-summary-large-working-set-size-threshold", cl::Hidden, cl::init(12500), cl::ZeroOrMore, cl::desc("The code working set size is considered large if the number of" " blocks required to reach the -profile-summary-cutoff-hot" " percentile exceeds this count."))
static const ProfileSummaryEntry & getEntryForPercentile(SummaryEntryVector &DS, uint64_t Percentile)
Find the summary entry for a desired percentile of counts.
bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
bool isFunctionEntryCold(const Function *F) const
Returns true if F has cold function entry.
bool isColdCountNthPercentile(int PercentileCutoff, uint64_t C) const
Returns true if count C is considered cold with regard to a given cold percentile cutoff value.
bool isFunctionHotnessUnknown(const Function &F) const
Returns true if the hotness of F is unknown.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static cl::opt< int > ProfileSummaryCutoffCold("profile-summary-cutoff-cold", cl::Hidden, cl::init(999999), cl::ZeroOrMore, cl::desc("A count is cold if it is below the minimum count" " to reach this percentile of total counts."))
A container for analyses that lazily runs them and caches their results.
Optional< uint64_t > getProfileCount(const CallBase &CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false) const
Returns the profile count for CallInst.
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"))
uint64_t getOrCompHotCountThreshold() const
Returns HotCountThreshold if set.
A special type used by analysis passes to provide an address that identifies that particular analysis...