diff options
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index fc908e1..7931001 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -383,18 +383,13 @@ bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) { isa<InvokeInst>(TI) || isa<CallBrInst>(TI))) return false; - MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof); + MDNode *WeightsNode = getValidBranchWeightMDNode(*TI); if (!WeightsNode) return false; // Check that the number of successors is manageable. assert(TI->getNumSuccessors() < UINT32_MAX && "Too many successors"); - // Ensure there are weights for all of the successors. Note that the first - // operand to the metadata node is a name, not a weight. - if (WeightsNode->getNumOperands() != TI->getNumSuccessors() + 1) - return false; - // Build up the final weights that will be used in a temporary buffer. // Compute the sum of all weights to later decide whether they need to // be scaled to fit in 32 bits. @@ -403,7 +398,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) { SmallVector<unsigned, 2> UnreachableIdxs; SmallVector<unsigned, 2> ReachableIdxs; - extractBranchWeights(*TI, Weights); + extractBranchWeights(WeightsNode, Weights); for (unsigned I = 0, E = Weights.size(); I != E; ++I) { WeightSum += Weights[I]; const LoopBlock SrcLoopBB = getLoopBlock(BB); |