diff options
author | Paul Kirth <paulkirth@google.com> | 2024-04-30 22:53:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-30 13:53:04 -0700 |
commit | 7538df90aee11603bce5146a3f34c06e9ef3f793 (patch) | |
tree | f70200025fad15cf2559bb80c11327a3ee04693a /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 05d04f0a057bc06324c02e00c2c73ee354999dde (diff) | |
download | llvm-7538df90aee11603bce5146a3f34c06e9ef3f793.zip llvm-7538df90aee11603bce5146a3f34c06e9ef3f793.tar.gz llvm-7538df90aee11603bce5146a3f34c06e9ef3f793.tar.bz2 |
[llvm][profdata][NFC] Support 64-bit weights in ProfDataUtils (#86607)
Since some places, like SimplifyCFG, work with 64-bit weights, we supply
an API in ProfDataUtils to extract the weights accordingly.
We change the API slightly to disambiguate the 64-bit version from the
32-bit version.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 4db7246..5a44a11 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1066,11 +1066,8 @@ static int ConstantIntSortPredicate(ConstantInt *const *P1, static void GetBranchWeights(Instruction *TI, SmallVectorImpl<uint64_t> &Weights) { MDNode *MD = TI->getMetadata(LLVMContext::MD_prof); - assert(MD); - for (unsigned i = 1, e = MD->getNumOperands(); i < e; ++i) { - ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(i)); - Weights.push_back(CI->getValue().getZExtValue()); - } + assert(MD && "Invalid branch-weight metadata"); + extractFromBranchWeightMD64(MD, Weights); // If TI is a conditional eq, the default case is the false case, // and the corresponding branch-weight data is at index 2. We swap the |