[PATCH] D128860: [llvm][NFC] Refactor code to use ProfDataUtils

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 14:04:18 PDT 2022


davidxl added inline comments.


================
Comment at: llvm/lib/IR/Metadata.cpp:1509
       "Looking for branch weights on something besides branch or select");
-
-  auto *ProfileData = getMetadata(LLVMContext::MD_prof);
-  if (!ProfileData || ProfileData->getNumOperands() != 3)
-    return false;
-
-  auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
-  if (!ProfDataName || !ProfDataName->getString().equals("branch_weights"))
-    return false;
-
-  auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
-  auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
-  if (!CITrue || !CIFalse)
+  SmallVector<uint32_t>Weights;
+  if(!extractBranchWeights(*this, Weights) || Weights.size() != 2)
----------------
missing space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128860/new/

https://reviews.llvm.org/D128860



More information about the llvm-commits mailing list