aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BranchProbabilityInfo.cpp
diff options
context:
space:
mode:
authorChristian Ulmann <christian.ulmann@nextsilicon.com>2023-01-19 12:04:53 +0100
committerChristian Ulmann <christian.ulmann@nextsilicon.com>2023-01-19 14:26:26 +0100
commite741b8c2e5200269f846bdd88ca98e44681fe8df (patch)
tree633474d1ab03298472179373e5b21ea8c9ec1e05 /llvm/lib/Analysis/BranchProbabilityInfo.cpp
parent7e5681cf295a267de0b8c2216f049d0285a73c4c (diff)
downloadllvm-e741b8c2e5200269f846bdd88ca98e44681fe8df.zip
llvm-e741b8c2e5200269f846bdd88ca98e44681fe8df.tar.gz
llvm-e741b8c2e5200269f846bdd88ca98e44681fe8df.tar.bz2
[llvm][ir] Purge MD_prof custom accessors
This commit purges direct accesses to MD_prof metadata and replaces them with the accessors provided from the utility file wherever possible. This commit can be seen as the first step towards switching the branch weights to 64 bits. See post here: https://discourse.llvm.org/t/extend-md-prof-branch-weights-metadata-from-32-to-64-bits/67492 Reviewed By: davidxl, paulkirth Differential Revision: https://reviews.llvm.org/D141393
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r--llvm/lib/Analysis/BranchProbabilityInfo.cpp9
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);