43 auto *SummaryMD = M->getProfileSummary(
true);
49 SummaryMD = M->getProfileSummary(
false);
58std::optional<uint64_t>
62 "We can only get profile count for call/invoke instruction.");
69 if (
Call.extractProfTotalWeight(TotalCount))
80 return !
F.getEntryCount();
93 if (
F->hasFnAttribute(Attribute::Cold))
97 auto FunctionCount =
F->getEntryCount();
101 return FunctionCount &&
isColdCount(*FunctionCount);
105void ProfileSummaryInfo::computeThresholds() {
106 auto &DetailedSummary = Summary->getDetailedSummary();
119 (*ColdCountThreshold)--;
121 (*HotCountThreshold)++;
124 "Cold count threshold should be less than hot count threshold!");
126 !Opts.scale_partial_sample_profile_working_set_size) {
127 HasHugeWorkingSetSize =
129 HasLargeWorkingSetSize =
134 double PartialProfileRatio = Summary->getPartialProfileRatio();
136 HotEntry.NumCounts * PartialProfileRatio *
137 Opts.partial_sample_profile_working_set_size_scale_factor);
138 HasHugeWorkingSetSize =
140 HasLargeWorkingSetSize =
145std::optional<uint64_t>
152 auto &DetailedSummary = Summary->getDetailedSummary();
161 return HasHugeWorkingSetSize && *HasHugeWorkingSetSize;
165 return HasLargeWorkingSetSize && *HasLargeWorkingSetSize;
169 return HotCountThreshold &&
C >= *HotCountThreshold;
173 return ColdCountThreshold &&
C <= *ColdCountThreshold;
197 return HotCountThreshold.value_or(
UINT64_MAX);
201 return ColdCountThreshold.value_or(0);
224 (Opts.partial_profile || Summary->isPartialProfile());
228 "Profile summary info",
false,
true)
253 OS <<
"Functions in " << M.getName() <<
" with hot/cold annotations: \n";
257 OS <<
" :hot entry ";
259 OS <<
" :cold entry ";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< unsigned > ColdCountThreshold("mfs-count-threshold", cl::desc("Minimum number of times a block must be executed to be retained."), cl::init(1), cl::Hidden)
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)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static cl::opt< unsigned > CountThreshold("hexagon-cext-threshold", cl::init(3), cl::Hidden, cl::desc("Minimum number of extenders to trigger replacement"))
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
LLVM_ABI std::optional< uint64_t > getBlockProfileCount(const BasicBlock *BB) const
Returns the estimated profile count of BB.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
bool hasProfileData() const
Return true if the function is annotated with profile data.
ImmutablePass class - This class is used to provide information that does not need to be run.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &)
static LLVM_ABI const ProfileSummaryEntry & getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile)
Find the summary entry for a desired percentile of counts.
static LLVM_ABI uint64_t getHotCountThreshold(const SummaryEntryVector &DS)
static LLVM_ABI uint64_t getColdCountThreshold(const SummaryEntryVector &DS)
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Analysis providing profile information.
LLVM_ABI uint64_t getOrCompColdCountThreshold() const
Returns ColdCountThreshold if set.
bool hasProfileSummary() const
Returns true if profile summary is available.
LLVM_ABI bool isFunctionHotnessUnknown(const Function &F) const
Returns true if the hotness of F is unknown.
LLVM_ABI ProfileSummaryInfo(const Module &M)
bool hasSampleProfile() const
Returns true if module M has sample profile.
bool isFunctionEntryHot(const FuncT *F) const
Returns true if F has hot function entry.
LLVM_ABI bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
LLVM_ABI 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.
LLVM_ABI void refresh(std::unique_ptr< ProfileSummary > &&Other=nullptr)
If a summary is provided as argument, use that.
LLVM_ABI 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.
LLVM_ABI bool hasPartialSampleProfile() const
Returns true if module M has partial-profile sample profile.
LLVM_ABI bool hasLargeWorkingSetSize() const
Returns true if the working set size of the code is considered large.
LLVM_ABI bool isColdCallSite(const CallBase &CB, BlockFrequencyInfo *BFI) const
Returns true if call site CB is considered cold.
LLVM_ABI bool isHotCallSite(const CallBase &CB, BlockFrequencyInfo *BFI) const
Returns true if the call site CB is considered hot.
LLVM_ABI bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
LLVM_ABI bool hasHugeWorkingSetSize() const
Returns true if the working set size of the code is considered huge.
LLVM_ABI uint64_t getOrCompHotCountThreshold() const
Returns HotCountThreshold if set.
LLVM_ABI std::optional< uint64_t > getProfileCount(const CallBase &CallInst, BlockFrequencyInfo *BFI) const
Returns the profile count for CallInst.
LLVM_ABI bool isFunctionEntryCold(const Function *F) const
Returns true if F has cold function entry.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
static LLVM_ABI ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
This is an optimization pass for GlobalISel generic memory operations.
const AnalysisOptions & getAnalysisOptions(const LLVMContext &C)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI cl::opt< unsigned > ProfileSummaryLargeWorkingSetSizeThreshold
LLVM_ABI cl::opt< int > ProfileSummaryCutoffHot
LLVM_ABI cl::opt< unsigned > ProfileSummaryHugeWorkingSetSizeThreshold
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...