25 const char *ProfileSummary::KindStr[2] = {
"InstrProf",
"SampleProfile"};
51 std::vector<Metadata *> Entries;
54 for (
auto &Entry : DetailedSummary) {
72 std::vector<Metadata *> Components;
73 Components.push_back(
getKeyValMD(Context,
"ProfileFormat", KindStr[PSK]));
83 Components.push_back(getDetailedSummaryMD(Context));
99 Val = cast<ConstantInt>(ValMD->getValue())->getZExtValue();
109 if (!KeyMD || !ValMD)
111 if (!KeyMD->
getString().
equals(Key) || !ValMD->getString().equals(Val))
126 for (
auto &&MDOp : EntriesMD->
operands()) {
137 if (!Op0 || !Op1 || !Op2)
139 Summary.emplace_back(cast<ConstantInt>(Op0->
getValue())->getZExtValue(),
140 cast<ConstantInt>(Op1->getValue())->getZExtValue(),
141 cast<ConstantInt>(Op2->getValue())->getZExtValue());
149 if (!isa<MDTuple>(MD))
151 MDTuple *Tuple = cast<MDTuple>(MD);
157 if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
160 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
166 uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount,
179 if (!
getVal(dyn_cast<MDTuple>(Tuple->
getOperand(5)),
"NumCounts", NumCounts))
188 return new ProfileSummary(SummaryKind, Summary, TotalCount, MaxCount,
189 MaxInternalCount, MaxFunctionCount, NumCounts,
static MDString * get(LLVMContext &Context, StringRef Str)
unsigned getNumOperands() const
Return number of MDNode operands.
static bool isKeyValuePair(MDTuple *MD, const char *Key, const char *Val)
static IntegerType * getInt64Ty(LLVMContext &C)
uint64_t getMaxInternalCount()
static bool getVal(MDTuple *MD, const char *Key, uint64_t &Val)
Metadata * getMD(LLVMContext &Context)
Return summary information as metadata.
ProfileSummary(Kind K, SummaryEntryVector DetailedSummary, uint64_t TotalCount, uint64_t MaxCount, uint64_t MaxInternalCount, uint64_t MaxFunctionCount, uint32_t NumCounts, uint32_t NumFunctions)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
This file contains the simple types necessary to represent the attributes associated with functions a...
static Metadata * getKeyValMD(LLVMContext &Context, const char *Key, uint64_t Val)
uint64_t getMaxFunctionCount()
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
StringRef getString() const
const MDOperand & getOperand(unsigned I) const
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 ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
uint32_t getNumFunctions()
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
op_range operands() const
std::vector< ProfileSummaryEntry > SummaryEntryVector