#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ProfileSummary.h"
#include "llvm/InitializePasses.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/Support/CommandLine.h"
#include <optional>
usingnamespacellvm;
static cl::opt<bool> PartialProfile(
"partial-profile", cl::Hidden, cl::init(false),
cl::desc("Specify the current profile is used as a partial profile."));
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."));
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."));
void ProfileSummaryInfo::refresh() { … }
std::optional<uint64_t> ProfileSummaryInfo::getProfileCount(
const CallBase &Call, BlockFrequencyInfo *BFI, bool AllowSynthetic) const { … }
bool ProfileSummaryInfo::isFunctionHotnessUnknown(const Function &F) const { … }
bool ProfileSummaryInfo::isFunctionEntryCold(const Function *F) const { … }
void ProfileSummaryInfo::computeThresholds() { … }
std::optional<uint64_t>
ProfileSummaryInfo::computeThreshold(int PercentileCutoff) const { … }
bool ProfileSummaryInfo::hasHugeWorkingSetSize() const { … }
bool ProfileSummaryInfo::hasLargeWorkingSetSize() const { … }
bool ProfileSummaryInfo::isHotCount(uint64_t C) const { … }
bool ProfileSummaryInfo::isColdCount(uint64_t C) const { … }
template <bool isHot>
bool ProfileSummaryInfo::isHotOrColdCountNthPercentile(int PercentileCutoff,
uint64_t C) const { … }
bool ProfileSummaryInfo::isHotCountNthPercentile(int PercentileCutoff,
uint64_t C) const { … }
bool ProfileSummaryInfo::isColdCountNthPercentile(int PercentileCutoff,
uint64_t C) const { … }
uint64_t ProfileSummaryInfo::getOrCompHotCountThreshold() const { … }
uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold() const { … }
bool ProfileSummaryInfo::isHotCallSite(const CallBase &CB,
BlockFrequencyInfo *BFI) const { … }
bool ProfileSummaryInfo::isColdCallSite(const CallBase &CB,
BlockFrequencyInfo *BFI) const { … }
bool ProfileSummaryInfo::hasPartialSampleProfile() const { … }
INITIALIZE_PASS(…)
ProfileSummaryInfoWrapperPass::ProfileSummaryInfoWrapperPass()
: … { … }
bool ProfileSummaryInfoWrapperPass::doInitialization(Module &M) { … }
bool ProfileSummaryInfoWrapperPass::doFinalization(Module &M) { … }
AnalysisKey ProfileSummaryAnalysis::Key;
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
ModuleAnalysisManager &) { … }
PreservedAnalyses ProfileSummaryPrinterPass::run(Module &M,
ModuleAnalysisManager &AM) { … }
char ProfileSummaryInfoWrapperPass::ID = …;