22 "sample-profile-max-propagate-iterations",
cl::init(100),
23 cl::desc(
"Maximum number of iterations to go through when propagating "
24 "sample block/edge weights through the CFG."));
28 cl::desc(
"Emit a warning if less than N% of records in the input profile "
29 "are matched to the IR."));
33 cl::desc(
"Emit a warning if less than N% of samples in the input profile "
34 "are matched to the IR."));
38 cl::desc(
"Use this option to turn off/on warnings about function with "
39 "samples but without debug information to use those samples. "));
43 cl::desc(
"Use profi to infer block and edge counts."));
45namespace sampleprofutil {
65 bool ProfAccForSymsInList) {
69 assert(PSI &&
"PSI is expected to be non null");
71 if (ProfAccForSymsInList)
86 unsigned &Count = SampleCoverage[FS][Loc];
87 bool FirstTime = (++Count == 1);
89 TotalUsedSamples += Samples;
99 auto I = SampleCoverage.
find(FS);
103 unsigned Count = (
I != SampleCoverage.
end()) ?
I->second.size() : 0;
108 for (
const auto &
I : FS->getCallsiteSamples())
109 for (
const auto &J :
I.second) {
124 unsigned Count = FS->getBodySamples().size();
127 for (
const auto &
I : FS->getCallsiteSamples())
128 for (
const auto &J :
I.second) {
144 for (
const auto &
I : FS->getBodySamples())
145 Total +=
I.second.getSamples();
148 for (
const auto &
I : FS->getCallsiteSamples())
149 for (
const auto &J :
I.second) {
164 unsigned Total)
const {
166 "number of used records cannot exceed the total number of records");
172 const char *FSDiscriminatorVar =
"__llvm_fs_discriminator__";
173 if (M->getGlobalVariable(FSDiscriminatorVar))
176 auto &
Context = M->getContext();
181 FSDiscriminatorVar)});
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This file provides the utility functions for the sampled PGO loader base implementation.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
iterator find(const_arg_type_t< KeyT > Val)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
LLVM_ABI bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
LLVM_ABI bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Representation of the samples collected for a function.
uint64_t getTotalSamples() const
Return the total number of samples collected inside the function.
unsigned countBodyRecords(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of sample records in the body of this profile.
unsigned countUsedRecords(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of sample records that were applied from this profile.
unsigned computeCoverage(unsigned Used, unsigned Total) const
Return the fraction of sample records used in this profile.
uint64_t countBodySamples(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of samples collected in the body of this profile.
bool markSamplesUsed(const FunctionSamples *FS, uint32_t LineOffset, uint32_t Discriminator, uint64_t Samples)
Mark as used the sample record for the given function samples at (LineOffset, Discriminator).
initializer< Ty > init(const Ty &Val)
void createFSDiscriminatorVariable(Module *M)
Create a global variable to flag FSDiscriminators are used.
bool callsiteIsHot(const FunctionSamples *CallsiteFS, ProfileSummaryInfo *PSI, bool ProfAccForSymsInList)
Return true if the given callsite is hot wrt to hot cutoff threshold.
This is an optimization pass for GlobalISel generic memory operations.
cl::opt< unsigned > SampleProfileSampleCoverage
cl::opt< unsigned > SampleProfileRecordCoverage
cl::opt< unsigned > SampleProfileMaxPropagateIterations
cl::opt< bool > SampleProfileUseProfi
cl::opt< bool > NoWarnSampleUnused
LLVM_ABI void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
Represents the relative location of an instruction.