35 cl::desc(
"A count is hot if it exceeds the minimum count to" 36 " reach this percentile of total counts."));
40 cl::desc(
"A count is cold if it is below the minimum count" 41 " to reach this percentile of total counts."));
44 "profile-summary-huge-working-set-size-threshold",
cl::Hidden,
46 cl::desc(
"The code working set size is considered huge if the number of" 47 " blocks required to reach the -profile-summary-cutoff-hot" 48 " percentile exceeds this count."));
51 "profile-summary-large-working-set-size-threshold",
cl::Hidden,
53 cl::desc(
"The code working set size is considered large if the number of" 54 " blocks required to reach the -profile-summary-cutoff-hot" 55 " percentile exceeds this count."));
61 cl::desc(
"A fixed hot count that overrides the count derived from" 62 " profile-summary-cutoff-hot"));
66 cl::desc(
"A fixed cold count that overrides the count derived from" 67 " profile-summary-cutoff-cold"));
71 uint64_t Percentile) {
73 return Entry.
Cutoff < Percentile;
87 bool ProfileSummaryInfo::computeSummary() {
107 bool AllowSynthetic) {
110 assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
111 "We can only get profile count for call/invoke instruction.");
131 if (!F || !computeSummary())
137 return FunctionCount &&
isHotCount(FunctionCount.getCount());
147 if (!F || !computeSummary())
154 uint64_t TotalCallCount = 0;
155 for (
const auto &BB : *F)
156 for (
const auto &
I : BB)
157 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
159 TotalCallCount += CallCount.getValue();
163 for (
const auto &BB : *F)
176 if (!F || !computeSummary())
183 uint64_t TotalCallCount = 0;
184 for (
const auto &BB : *F)
185 for (
const auto &
I : BB)
186 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
188 TotalCallCount += CallCount.getValue();
192 for (
const auto &BB : *F)
201 if (!F || !computeSummary())
208 uint64_t TotalCallCount = 0;
209 for (
const auto &BB : *F)
210 for (
const auto &
I : BB)
211 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
213 TotalCallCount += CallCount.getValue();
217 for (
const auto &BB : *F)
231 if (!computeSummary())
237 return FunctionCount &&
isColdCount(FunctionCount.getCount());
241 void ProfileSummaryInfo::computeThresholds() {
242 if (!computeSummary())
244 auto &DetailedSummary = Summary->getDetailedSummary();
247 HotCountThreshold = HotEntry.MinCount;
252 ColdCountThreshold = ColdEntry.MinCount;
255 assert(ColdCountThreshold <= HotCountThreshold &&
256 "Cold count threshold cannot exceed hot count threshold!");
257 HasHugeWorkingSetSize =
259 HasLargeWorkingSetSize =
264 if (!computeSummary())
266 auto iter = ThresholdCache.
find(PercentileCutoff);
267 if (iter != ThresholdCache.
end()) {
270 auto &DetailedSummary = Summary->getDetailedSummary();
279 if (!HasHugeWorkingSetSize)
281 return HasHugeWorkingSetSize && HasHugeWorkingSetSize.
getValue();
285 if (!HasLargeWorkingSetSize)
287 return HasLargeWorkingSetSize && HasLargeWorkingSetSize.
getValue();
291 if (!HotCountThreshold)
293 return HotCountThreshold && C >= HotCountThreshold.
getValue();
297 if (!ColdCountThreshold)
299 return ColdCountThreshold && C <= ColdCountThreshold.
getValue();
308 if (!HotCountThreshold)
314 if (!ColdCountThreshold)
316 return ColdCountThreshold ? ColdCountThreshold.
getValue() : 0;
355 "Profile summary info",
false,
true)
382 OS <<
"Functions in " << M.
getName() <<
" with hot/cold annotations: \n";
386 OS <<
" :hot entry ";
388 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.