diff options
author | Paul Kirth <paulkirth@google.com> | 2022-07-27 21:44:24 +0000 |
---|---|---|
committer | Paul Kirth <paulkirth@google.com> | 2022-08-03 00:09:45 +0000 |
commit | d434e40f398e3144c69d57d2a142d35e2f760a8e (patch) | |
tree | 00c21846399cb3514183698bee5e2e77c3a2acf7 /llvm/lib/CodeGen/SelectOptimize.cpp | |
parent | 6ac30fa6e94118613fd27f0fd896a86852eeea7a (diff) | |
download | llvm-d434e40f398e3144c69d57d2a142d35e2f760a8e.zip llvm-d434e40f398e3144c69d57d2a142d35e2f760a8e.tar.gz llvm-d434e40f398e3144c69d57d2a142d35e2f760a8e.tar.bz2 |
[llvm][NFC] Refactor code to use ProfDataUtils
In this patch we replace common code patterns with the use of utility
functions for dealing with profiling metadata. There should be no change
in functionality, as the existing checks should be preserved in all
cases.
Reviewed By: bogner, davidxl
Differential Revision: https://reviews.llvm.org/D128860
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectOptimize.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp index 011f55e..a7a6987 100644 --- a/llvm/lib/CodeGen/SelectOptimize.cpp +++ b/llvm/lib/CodeGen/SelectOptimize.cpp @@ -29,6 +29,7 @@ #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instruction.h" +#include "llvm/IR/ProfDataUtils.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Support/ScaledNumber.h" @@ -655,7 +656,7 @@ bool SelectOptimize::hasExpensiveColdOperand( const SmallVector<SelectInst *, 2> &ASI) { bool ColdOperand = false; uint64_t TrueWeight, FalseWeight, TotalWeight; - if (ASI.front()->extractProfMetadata(TrueWeight, FalseWeight)) { + if (extractBranchWeights(*ASI.front(), TrueWeight, FalseWeight)) { uint64_t MinWeight = std::min(TrueWeight, FalseWeight); TotalWeight = TrueWeight + FalseWeight; // Is there a path with frequency <ColdOperandThreshold% (default:20%) ? @@ -750,7 +751,7 @@ void SelectOptimize::getExclBackwardsSlice(Instruction *I, bool SelectOptimize::isSelectHighlyPredictable(const SelectInst *SI) { uint64_t TrueWeight, FalseWeight; - if (SI->extractProfMetadata(TrueWeight, FalseWeight)) { + if (extractBranchWeights(*SI, TrueWeight, FalseWeight)) { uint64_t Max = std::max(TrueWeight, FalseWeight); uint64_t Sum = TrueWeight + FalseWeight; if (Sum != 0) { @@ -959,7 +960,7 @@ SelectOptimize::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost, const SelectInst *SI) { Scaled64 PredPathCost; uint64_t TrueWeight, FalseWeight; - if (SI->extractProfMetadata(TrueWeight, FalseWeight)) { + if (extractBranchWeights(*SI, TrueWeight, FalseWeight)) { uint64_t SumWeight = TrueWeight + FalseWeight; if (SumWeight != 0) { PredPathCost = TrueCost * Scaled64::get(TrueWeight) + |