48 std::vector<Metadata *> Entries;
51 for (
auto &
Entry : DetailedSummary) {
69 const char *KindStr[3] = {
"InstrProf",
"CSInstrProf",
"SampleProfile"};
71 getKeyValMD(Context,
"ProfileFormat", KindStr[PSK]),
78 getDetailedSummaryMD(Context),
95 Val = cast<ConstantInt>(ValMD->getValue())->getZExtValue();
105 if (!KeyMD || !ValMD)
107 if (!KeyMD->
getString().
equals(Key) || !ValMD->getString().equals(Val))
122 for (
auto &&MDOp : EntriesMD->
operands()) {
133 if (!Op0 || !Op1 || !Op2)
135 Summary.emplace_back(cast<ConstantInt>(Op0->
getValue())->getZExtValue(),
136 cast<ConstantInt>(Op1->getValue())->getZExtValue(),
137 cast<ConstantInt>(Op2->getValue())->getZExtValue());
143 MDTuple *Tuple = dyn_cast_or_null<MDTuple>(MD);
149 if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
152 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
155 else if (
isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD),
"ProfileFormat",
161 uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount,
174 if (!
getVal(dyn_cast<MDTuple>(Tuple->
getOperand(5)),
"NumCounts", NumCounts))
183 return new ProfileSummary(SummaryKind, std::move(Summary), TotalCount,
184 MaxCount, MaxInternalCount, MaxFunctionCount,
185 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 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.