33 cl::desc(
"A count is hot if it exceeds the minimum count to" 34 " reach this percentile of total counts."));
38 cl::desc(
"A count is cold if it is below the minimum count" 39 " to reach this percentile of total counts."));
42 "profile-summary-huge-working-set-size-threshold",
cl::Hidden,
44 cl::desc(
"The code working set size is considered huge if the number of" 45 " blocks required to reach the -profile-summary-cutoff-hot" 46 " percentile exceeds this count."));
49 "profile-summary-large-working-set-size-threshold",
cl::Hidden,
51 cl::desc(
"The code working set size is considered large if the number of" 52 " blocks required to reach the -profile-summary-cutoff-hot" 53 " percentile exceeds this count."));
59 cl::desc(
"A fixed hot count that overrides the count derived from" 60 " profile-summary-cutoff-hot"));
64 cl::desc(
"A fixed cold count that overrides the count derived from" 65 " profile-summary-cutoff-cold"));
69 uint64_t Percentile) {
71 return Entry.
Cutoff < Percentile;
85 bool ProfileSummaryInfo::computeSummary() {
105 bool AllowSynthetic) {
108 assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
109 "We can only get profile count for call/invoke instruction.");
129 if (!F || !computeSummary())
135 return FunctionCount &&
isHotCount(FunctionCount.getCount());
145 if (!F || !computeSummary())
152 uint64_t TotalCallCount = 0;
153 for (
const auto &BB : *F)
154 for (
const auto &
I : BB)
155 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
157 TotalCallCount += CallCount.getValue();
161 for (
const auto &BB : *F)
174 if (!F || !computeSummary())
181 uint64_t TotalCallCount = 0;
182 for (
const auto &BB : *F)
183 for (
const auto &
I : BB)
184 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
186 TotalCallCount += CallCount.getValue();
190 for (
const auto &BB : *F)
199 if (!F || !computeSummary())
206 uint64_t TotalCallCount = 0;
207 for (
const auto &BB : *F)
208 for (
const auto &
I : BB)
209 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
211 TotalCallCount += CallCount.getValue();
215 for (
const auto &BB : *F)
229 if (!computeSummary())
235 return FunctionCount &&
isColdCount(FunctionCount.getCount());
239 void ProfileSummaryInfo::computeThresholds() {
240 if (!computeSummary())
242 auto &DetailedSummary = Summary->getDetailedSummary();
245 HotCountThreshold = HotEntry.MinCount;
250 ColdCountThreshold = ColdEntry.MinCount;
253 assert(ColdCountThreshold <= HotCountThreshold &&
254 "Cold count threshold cannot exceed hot count threshold!");
255 HasHugeWorkingSetSize =
257 HasLargeWorkingSetSize =
262 if (!computeSummary())
264 auto iter = ThresholdCache.
find(PercentileCutoff);
265 if (iter != ThresholdCache.
end()) {
268 auto &DetailedSummary = Summary->getDetailedSummary();
277 if (!HasHugeWorkingSetSize)
279 return HasHugeWorkingSetSize && HasHugeWorkingSetSize.
getValue();
283 if (!HasLargeWorkingSetSize)
285 return HasLargeWorkingSetSize && HasLargeWorkingSetSize.
getValue();
289 if (!HotCountThreshold)
291 return HotCountThreshold && C >= HotCountThreshold.
getValue();
295 if (!ColdCountThreshold)
297 return ColdCountThreshold && C <= ColdCountThreshold.
getValue();
306 if (!HotCountThreshold)
312 if (!ColdCountThreshold)
314 return ColdCountThreshold ? ColdCountThreshold.
getValue() : 0;
353 "Profile summary info",
false,
true)
380 OS <<
"Functions in " << M.
getName() <<
" with hot/cold annotations: \n";
384 OS <<
" :hot entry ";
386 OS <<
" :cold entry ";
Optional< uint64_t > getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic=false) const
Returns the estimated profile count of BB.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
uint32_t Cutoff
The required percentile of counts.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
bool isColdCount(uint64_t C)
Returns true if count C is considered cold.
Analysis providing profile information.
Metadata * getProfileSummary(bool IsCS)
Returns profile summary metadata.
bool isFunctionHotInCallGraphNthPercentile(int PercentileCutoff, const Function *F, BlockFrequencyInfo &BFI)
Returns true if F contains hot code with regard to a given hot percentile cutoff value.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
StringRef getName() const
Get a short "name" for the module.
uint64_t getOrCompHotCountThreshold()
Returns HotCountThreshold if set.
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 isHotCount(uint64_t C)
Returns true if count C is considered hot.
bool isFunctionEntryCold(const Function *F)
Returns true if F has cold function entry.
bool isHotCallSite(const CallSite &CS, BlockFrequencyInfo *BFI)
Returns true if CallSite CS is considered hot.
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"))
uint64_t getOrCompColdCountThreshold()
Returns ColdCountThreshold if set.
Result run(Module &M, ModuleAnalysisManager &)
bool isFunctionHotInCallGraph(const Function *F, BlockFrequencyInfo &BFI)
Returns true if F contains hot code.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
InstrTy * getInstruction() const
auto partition_point(R &&Range, Predicate P) -> decltype(adl_begin(Range))
Binary search for the first iterator in a range where a predicate is false.
bool isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI)
Returns true if BasicBlock BB is considered cold.
bool hasLargeWorkingSetSize()
Returns true if the working set size of the code is considered large.
ProfileSummaryInfo(Module &M)
static cl::opt< unsigned > CountThreshold("hexagon-cext-threshold", cl::init(3), cl::Hidden, cl::ZeroOrMore, cl::desc("Minimum number of extenders to trigger replacement"))
const T & getValue() const LLVM_LVALUE_FUNCTION
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
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)
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
bool hasSampleProfile()
Returns true if module M has sample profile.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
ProfileCount getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
bool isHotCountNthPercentile(int PercentileCutoff, uint64_t C)
Returns true if count C is considered hot with regard to a given hot percentile cutoff value...
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", "Profile summary info", false, true) ProfileSummaryInfoWrapperPass
bool isHotBlockNthPercentile(int PercentileCutoff, const BasicBlock *BB, BlockFrequencyInfo *BFI)
Returns true if BasicBlock BB is considered hot with regard to a given hot percentile cutoff value...
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.
Optional< uint64_t > getProfileCount(const Instruction *CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false)
Returns the profile count for CallInst.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
ImmutablePass class - This class is used to provide information that does not need to be run...
Module.h This file contains the declarations for the Module class.
void initializeProfileSummaryInfoWrapperPassPass(PassRegistry &)
bool isFunctionColdInCallGraph(const Function *F, BlockFrequencyInfo &BFI)
Returns true if F contains only cold code.
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 isFunctionEntryHot(const Function *F)
Returns true if F has hot function entry.
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."))
bool isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI)
Returns true if BasicBlock BB is considered hot.
bool isColdCallSite(const CallSite &CS, BlockFrequencyInfo *BFI)
Returns true if Callsite CS is considered cold.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasHugeWorkingSetSize()
Returns true if the working set size of the code is considered huge.
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.
std::vector< ProfileSummaryEntry > SummaryEntryVector
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"))
A special type used by analysis passes to provide an address that identifies that particular analysis...
static const ProfileSummaryEntry & getEntryForPercentile(SummaryEntryVector &DS, uint64_t Percentile)
const BasicBlock * getParent() const
FunTy * getCaller() const
Return the caller function for this call site.