From 54ee51b2fb830866836e803194703b2871a79af0 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 12 Apr 2018 19:48:05 +0000 Subject: [PATCH] Simplify; NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329943 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/ProfileSummary.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/IR/ProfileSummary.cpp b/lib/IR/ProfileSummary.cpp index 2b24d125112..6635d4cfc7b 100644 --- a/lib/IR/ProfileSummary.cpp +++ b/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 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(MD)) - return nullptr; - MDTuple *Tuple = cast(MD); - if (Tuple->getNumOperands() != 8) + MDTuple *Tuple = dyn_cast_or_null(MD); + if (!Tuple || Tuple->getNumOperands() != 8) return nullptr; auto &FormatMD = Tuple->getOperand(0); -- 2.11.0