25 const char *ProfileSummary::KindStr[2] = {
"InstrProf",
"SampleProfile"};
51 std::vector<Metadata *> Entries;
54 for (
auto &Entry : DetailedSummary) {
73 getKeyValMD(Context,
"ProfileFormat", KindStr[PSK]),
80 getDetailedSummaryMD(Context),
97 Val = cast<ConstantInt>(ValMD->getValue())->getZExtValue();
107 if (!KeyMD || !ValMD)
109 if (!KeyMD->
getString().
equals(Key) || !ValMD->getString().equals(Val))
124 for (
auto &&MDOp : EntriesMD->
operands()) {
135 if (!Op0 || !Op1 || !Op2)
137 Summary.emplace_back(cast<ConstantInt>(Op0->
getValue())->getZExtValue(),
138 cast<ConstantInt>(Op1->getValue())->getZExtValue(),
139 cast<ConstantInt>(Op2->getValue())->getZExtValue());
145 MDTuple *Tuple = dyn_cast_or_null<MDTuple>(MD);
151 if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
154 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
160 uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount,
173 if (!
getVal(dyn_cast<MDTuple>(Tuple->
getOperand(5)),
"NumCounts", NumCounts))
182 return new ProfileSummary(SummaryKind, std::move(Summary), TotalCount,
183 MaxCount, MaxInternalCount, MaxFunctionCount,
184 NumCounts, NumFunctions);
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
This class represents lattice values for constants.
static MDString * get(LLVMContext &Context, StringRef Str)
static bool isKeyValuePair(MDTuple *MD, const char *Key, const char *Val)
const MDOperand & getOperand(unsigned I) const
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)
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)
op_range operands() const
uint64_t getMaxFunctionCount()
StringRef getString() const
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.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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.
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 ...
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)
std::vector< ProfileSummaryEntry > SummaryEntryVector
unsigned getNumOperands() const
Return number of MDNode operands.