Go to the documentation of this file.
56 std::vector<Metadata *> Entries;
59 for (
auto &Entry : DetailedSummary) {
81 bool AddPartialProfileRatioField) {
82 const char *KindStr[3] = {
"InstrProf",
"CSInstrProf",
"SampleProfile"};
96 if (AddPartialProfileRatioField)
99 Components.push_back(getDetailedSummaryMD(
Context));
111 if (!KeyMD || !ValMD)
121 Val = cast<ConstantInt>(ValMD->getValue())->getZExtValue();
129 Val = cast<ConstantFP>(ValMD->getValue())->getValueAPF().convertToDouble();
141 if (!KeyMD || !ValMD)
158 for (
auto &&MDOp : EntriesMD->
operands()) {
159 MDTuple *EntryMD = dyn_cast<MDTuple>(MDOp);
163 dyn_cast<ConstantAsMetadata>(EntryMD->
getOperand(0));
165 dyn_cast<ConstantAsMetadata>(EntryMD->
getOperand(1));
167 dyn_cast<ConstantAsMetadata>(EntryMD->
getOperand(2));
169 if (!Op0 || !Op1 || !Op2)
171 Summary.emplace_back(cast<ConstantInt>(Op0->
getValue())->getZExtValue(),
172 cast<ConstantInt>(Op1->
getValue())->getZExtValue(),
173 cast<ConstantInt>(Op2->
getValue())->getZExtValue());
180 template <
typename ValueType>
195 MDTuple *Tuple = dyn_cast_or_null<MDTuple>(MD);
202 if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
205 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
208 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
214 uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount,
238 double PartialProfileRatio = 0;
239 if (!
getOptionalVal(Tuple,
I,
"PartialProfileRatio", PartialProfileRatio))
246 MaxCount, MaxInternalCount, MaxFunctionCount,
247 NumCounts, NumFunctions, IsPartialProfile,
248 PartialProfileRatio);
252 OS <<
"Total functions: " << NumFunctions <<
"\n";
253 OS <<
"Maximum function count: " << MaxFunctionCount <<
"\n";
254 OS <<
"Maximum block count: " << MaxCount <<
"\n";
255 OS <<
"Total number of blocks: " << NumCounts <<
"\n";
256 OS <<
"Total count: " << TotalCount <<
"\n";
260 OS <<
"Detailed summary:\n";
261 for (
const auto &Entry : DetailedSummary) {
262 OS << Entry.NumCounts <<
" blocks with count >= " << Entry.MinCount
264 <<
format(
"%0.6g", (
float)Entry.Cutoff /
Scale * 100)
265 <<
" percentage of the total counts.\n";
This is an optimization pass for GlobalISel generic memory operations.
static ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt32Ty(LLVMContext &C)
op_range operands() const
bool isPartialProfile() const
unsigned getNumOperands() const
Return number of MDNode operands.
void printDetailedSummary(raw_ostream &OS) const
static Metadata * getKeyValMD(LLVMContext &Context, const char *Key, uint64_t Val)
uint32_t getNumCounts() const
double getPartialProfileRatio() const
static bool isKeyValuePair(MDTuple *MD, const char *Key, const char *Val)
static Type * getDoubleTy(LLVMContext &C)
Metadata * getMD(LLVMContext &Context, bool AddPartialField=true, bool AddPartialProfileRatioField=true)
Return summary information as metadata.
uint32_t getNumFunctions() const
uint64_t getMaxInternalCount() const
uint64_t getTotalCount() const
This class implements an extremely fast bulk output stream that can only output to a stream.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static bool getSummaryFromMD(MDTuple *MD, SummaryEntryVector &Summary)
static ConstantAsMetadata * getValMD(MDTuple *MD, const char *Key)
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
uint64_t getMaxFunctionCount() const
const MDOperand & getOperand(unsigned I) const
void printSummary(raw_ostream &OS) const
ProfileSummary(Kind K, const SummaryEntryVector &DetailedSummary, uint64_t TotalCount, uint64_t MaxCount, uint64_t MaxInternalCount, uint64_t MaxFunctionCount, uint32_t NumCounts, uint32_t NumFunctions, bool Partial=false, double PartialProfileRatio=0)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
static MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static bool getOptionalVal(MDTuple *Tuple, unsigned &Idx, const char *Key, ValueType &Value)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
std::vector< ProfileSummaryEntry > SummaryEntryVector
static Metadata * getKeyFPValMD(LLVMContext &Context, const char *Key, double Val)
static IntegerType * getInt64Ty(LLVMContext &C)
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
static bool getVal(MDTuple *MD, const char *Key, uint64_t &Val)
StringRef getString() const
LLVM Value Representation.
uint64_t getMaxCount() const