#include "llvm/IR/ProfDataUtils.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/CommandLine.h"
usingnamespacellvm;
namespace {
constexpr unsigned MinBWOps = …;
constexpr unsigned MinVPOps = …;
bool isTargetMD(const MDNode *ProfData, const char *Name, unsigned MinOps) { … }
template <typename T,
typename = typename std::enable_if<std::is_arithmetic_v<T>>>
static void extractFromBranchWeightMD(const MDNode *ProfileData,
SmallVectorImpl<T> &Weights) { … }
}
namespace llvm {
bool hasProfMD(const Instruction &I) { … }
bool isBranchWeightMD(const MDNode *ProfileData) { … }
bool isValueProfileMD(const MDNode *ProfileData) { … }
bool hasBranchWeightMD(const Instruction &I) { … }
bool hasCountTypeMD(const Instruction &I) { … }
bool hasValidBranchWeightMD(const Instruction &I) { … }
bool hasBranchWeightOrigin(const Instruction &I) { … }
bool hasBranchWeightOrigin(const MDNode *ProfileData) { … }
unsigned getBranchWeightOffset(const MDNode *ProfileData) { … }
unsigned getNumBranchWeights(const MDNode &ProfileData) { … }
MDNode *getBranchWeightMDNode(const Instruction &I) { … }
MDNode *getValidBranchWeightMDNode(const Instruction &I) { … }
void extractFromBranchWeightMD32(const MDNode *ProfileData,
SmallVectorImpl<uint32_t> &Weights) { … }
void extractFromBranchWeightMD64(const MDNode *ProfileData,
SmallVectorImpl<uint64_t> &Weights) { … }
bool extractBranchWeights(const MDNode *ProfileData,
SmallVectorImpl<uint32_t> &Weights) { … }
bool extractBranchWeights(const Instruction &I,
SmallVectorImpl<uint32_t> &Weights) { … }
bool extractBranchWeights(const Instruction &I, uint64_t &TrueVal,
uint64_t &FalseVal) { … }
bool extractProfTotalWeight(const MDNode *ProfileData, uint64_t &TotalVal) { … }
bool extractProfTotalWeight(const Instruction &I, uint64_t &TotalVal) { … }
void setBranchWeights(Instruction &I, ArrayRef<uint32_t> Weights,
bool IsExpected) { … }
void scaleProfData(Instruction &I, uint64_t S, uint64_t T) { … }
}