summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/IR/ProfileSummary.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/llvm/lib/IR/ProfileSummary.cpp b/llvm/lib/IR/ProfileSummary.cpp
index 2b24d125112..6635d4cfc7b 100644
--- a/llvm/lib/IR/ProfileSummary.cpp
+++ b/llvm/lib/IR/ProfileSummary.cpp
@@ -69,18 +69,16 @@ Metadata *ProfileSummary::getDetailedSummaryMD(LLVMContext &Context) {
// "SampleProfile"). The rest of the elements of the outer MDTuple are specific
// to the kind of profile summary as returned by getFormatSpecificMD.
Metadata *ProfileSummary::getMD(LLVMContext &Context) {
- std::vector<Metadata *> Components;
- Components.push_back(getKeyValMD(Context, "ProfileFormat", KindStr[PSK]));
-
- Components.push_back(getKeyValMD(Context, "TotalCount", getTotalCount()));
- Components.push_back(getKeyValMD(Context, "MaxCount", getMaxCount()));
- Components.push_back(
- getKeyValMD(Context, "MaxInternalCount", getMaxInternalCount()));
- Components.push_back(
- getKeyValMD(Context, "MaxFunctionCount", getMaxFunctionCount()));
- Components.push_back(getKeyValMD(Context, "NumCounts", getNumCounts()));
- Components.push_back(getKeyValMD(Context, "NumFunctions", getNumFunctions()));
- Components.push_back(getDetailedSummaryMD(Context));
+ Metadata *Components[] = {
+ getKeyValMD(Context, "ProfileFormat", KindStr[PSK]),
+ getKeyValMD(Context, "TotalCount", getTotalCount()),
+ getKeyValMD(Context, "MaxCount", getMaxCount()),
+ getKeyValMD(Context, "MaxInternalCount", getMaxInternalCount()),
+ getKeyValMD(Context, "MaxFunctionCount", getMaxFunctionCount()),
+ getKeyValMD(Context, "NumCounts", getNumCounts()),
+ getKeyValMD(Context, "NumFunctions", getNumFunctions()),
+ getDetailedSummaryMD(Context),
+ };
return MDTuple::get(Context, Components);
}
@@ -144,12 +142,8 @@ static bool getSummaryFromMD(MDTuple *MD, SummaryEntryVector &Summary) {
}
ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) {
- if (!MD)
- return nullptr;
- if (!isa<MDTuple>(MD))
- return nullptr;
- MDTuple *Tuple = cast<MDTuple>(MD);
- if (Tuple->getNumOperands() != 8)
+ MDTuple *Tuple = dyn_cast_or_null<MDTuple>(MD);
+ if (!Tuple || Tuple->getNumOperands() != 8)
return nullptr;
auto &FormatMD = Tuple->getOperand(0);
OpenPOWER on IntegriCloud