[llvm] r329943 - Simplify; NFCI

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 12:48:05 PDT 2018


Author: gbiv
Date: Thu Apr 12 12:48:05 2018
New Revision: 329943

URL: http://llvm.org/viewvc/llvm-project?rev=329943&view=rev
Log:
Simplify; NFCI

Modified:
    llvm/trunk/lib/IR/ProfileSummary.cpp

Modified: llvm/trunk/lib/IR/ProfileSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ProfileSummary.cpp?rev=329943&r1=329942&r2=329943&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ProfileSummary.cpp (original)
+++ llvm/trunk/lib/IR/ProfileSummary.cpp Thu Apr 12 12:48:05 2018
@@ -69,18 +69,16 @@ Metadata *ProfileSummary::getDetailedSum
 // "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
 }
 
 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);




More information about the llvm-commits mailing list