34 cl::desc(
"A count is hot if it exceeds the minimum count to" 35 " reach this percentile of total counts."));
39 cl::desc(
"A count is cold if it is below the minimum count" 40 " to reach this percentile of total counts."));
44 cl::desc(
"If the sample profile is accurate, we will mark all un-sampled " 45 "callsite as cold. Otherwise, treat un-sampled callsites as if " 46 "we have no profile."));
48 "profile-summary-huge-working-set-size-threshold",
cl::Hidden,
50 cl::desc(
"The code working set size is considered huge if the number of" 51 " blocks required to reach the -profile-summary-cutoff-hot" 52 " percentile exceeds this count."));
56 uint64_t Percentile) {
58 return Entry.
Cutoff < Percentile;
73 bool ProfileSummaryInfo::computeSummary() {
88 assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
89 "We can only get profile count for call/invoke instruction.");
109 if (!F || !computeSummary())
115 return FunctionCount &&
isHotCount(FunctionCount.getCount());
125 if (!F || !computeSummary())
132 uint64_t TotalCallCount = 0;
133 for (
const auto &BB : *F)
134 for (
const auto &
I : BB)
135 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
137 TotalCallCount += CallCount.getValue();
141 for (
const auto &BB : *F)
154 if (!F || !computeSummary())
161 uint64_t TotalCallCount = 0;
162 for (
const auto &BB : *F)
163 for (
const auto &
I : BB)
164 if (isa<CallInst>(
I) || isa<InvokeInst>(
I))
166 TotalCallCount += CallCount.getValue();
170 for (
const auto &BB : *F)
184 if (!computeSummary())
190 return FunctionCount &&
isColdCount(FunctionCount.getCount());
194 void ProfileSummaryInfo::computeThresholds() {
195 if (!computeSummary())
197 auto &DetailedSummary = Summary->getDetailedSummary();
200 HotCountThreshold = HotEntry.MinCount;
203 ColdCountThreshold = ColdEntry.MinCount;
204 HasHugeWorkingSetSize =
209 if (!HasHugeWorkingSetSize)
211 return HasHugeWorkingSetSize && HasHugeWorkingSetSize.
getValue();
215 if (!HotCountThreshold)
217 return HotCountThreshold && C >= HotCountThreshold.
getValue();
221 if (!ColdCountThreshold)
223 return ColdCountThreshold && C <= ColdCountThreshold.
getValue();
227 if (!HotCountThreshold)
229 return HotCountThreshold && HotCountThreshold.
getValue();
233 if (!ColdCountThreshold)
235 return ColdCountThreshold && ColdCountThreshold.
getValue();
271 "Profile summary info",
false,
true)
298 OS <<
"Functions in " << M.
getName() <<
" with hot/cold annotations: \n";
302 OS <<
" :hot entry ";
304 OS <<
" :cold entry ";
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.
Compute iterated dominance frontiers using a linear time algorithm.
A Module instance is used to store all the information related to an LLVM module. ...
bool isColdBB(const BasicBlock *B, BlockFrequencyInfo *BFI)
Returns true if BasicBlock B is considered cold.
bool isColdCount(uint64_t C)
Returns true if count C is considered cold.
static cl::opt< bool > ProfileSampleAccurate("profile-sample-accurate", 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."))
Analysis providing profile information.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Optional< uint64_t > getProfileCount(const Instruction *CallInst, BlockFrequencyInfo *BFI)
Returns the profile count for CallInst.
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 F is a hot function.
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.
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.
ProfileCount getEntryCount() const
Get the entry count for this function.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
bool isHotBB(const BasicBlock *B, BlockFrequencyInfo *BFI)
Returns true if BasicBlock B is considered hot.
InstrTy * getInstruction() const
Metadata * getProfileSummary()
Returns profile summary metadata.
ProfileSummaryInfo(Module &M)
const T & getValue() const LLVM_LVALUE_FUNCTION
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
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 ...
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", "Profile summary info", false, true) ProfileSummaryInfoWrapperPass
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.
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."))
FunTy * getCaller() const
Return the caller function for this call site.
bool isFunctionEntryHot(const Function *F)
Returns true if F has hot function entry.
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
bool hasProfileData() const
Return true if the function is annotated with profile data.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Optional< uint64_t > getBlockProfileCount(const BasicBlock *BB) const
Returns the estimated profile count of BB.
static const ProfileSummaryEntry & getEntryForPercentile(SummaryEntryVector &DS, uint64_t Percentile)
const BasicBlock * getParent() const