LLVM: lib/Analysis/BranchProbabilityInfo.cpp File Reference (original) (raw)
Go to the source code of this file.
| Macros | |
|---|---|
| #define | DEBUG_TYPE "branch-prob" |
| Enumerations | |
|---|---|
| enum class | BlockExecWeight : std::uint32_t { ZERO = 0x0 , LOWEST_NON_ZERO = 0x1 , UNREACHABLE = ZERO , NORETURN = LOWEST_NON_ZERO , UNWIND = LOWEST_NON_ZERO , COLD = 0xffff , DEFAULT = 0xfffff } |
| Set of dedicated "absolute" execution weights for a block. More... |
| Variables | |
|---|---|
| static cl::opt< bool > | PrintBranchProb ("print-bpi", cl::init(false), cl::Hidden, cl::desc("Print the branch probability info.")) |
| static cl::opt< std::string > | PrintBranchProbFuncName ("print-bpi-func-name", cl::Hidden, cl::desc("The option to specify the name of the function " "whose branch probability info is printed.")) |
| branch | prob |
| branch Branch Probability | Analysis |
| branch Branch Probability | false |
| static const uint32_t | LBH_TAKEN_WEIGHT = 124 |
| static const uint32_t | LBH_NONTAKEN_WEIGHT = 4 |
| static const BranchProbability | UR_TAKEN_PROB = BranchProbability::getRaw(1) |
| Unreachable-terminating branch taken probability. | |
| static const uint32_t | PH_TAKEN_WEIGHT = 20 |
| Heuristics and lookup tables for non-loop branches: Pointer Heuristics (PH) | |
| static const uint32_t | PH_NONTAKEN_WEIGHT = 12 |
| static const ProbabilityTable | PointerTable |
| Pointer comparisons: | |
| static const uint32_t | ZH_TAKEN_WEIGHT = 20 |
| Zero Heuristics (ZH) | |
| static const uint32_t | ZH_NONTAKEN_WEIGHT = 12 |
| static const ProbabilityTable | ICmpWithZeroTable |
| Integer compares with 0: | |
| static const ProbabilityTable | ICmpWithMinusOneTable |
| Integer compares with -1: | |
| static const ProbabilityTable | ICmpWithOneTable |
| Integer compares with 1: | |
| static const ProbabilityTable | ICmpWithLibCallTable |
| strcmp and similar functions return zero, negative, or positive, if the first string is equal, less, or greater than the second. | |
| static const uint32_t | FPH_TAKEN_WEIGHT = 20 |
| static const uint32_t | FPH_NONTAKEN_WEIGHT = 12 |
| static const uint32_t | FPH_ORD_WEIGHT = 1024 * 1024 - 1 |
| This is the probability for an ordered floating point comparison. | |
| static const uint32_t | FPH_UNO_WEIGHT = 1 |
| This is the probability for an unordered floating point comparison, it means one or two of the operands are NaN. | |
| static const ProbabilityTable | FCmpTable |
| Floating-Point compares: |
◆ DEBUG_TYPE
#define DEBUG_TYPE "branch-prob"
◆ ProbabilityList
◆ ProbabilityTable
◆ BlockExecWeight
| enum class BlockExecWeight : std::uint32_t | strong |
|---|
Set of dedicated "absolute" execution weights for a block.
These weights are meaningful relative to each other and their derivatives only.
| Enumerator | |
|---|---|
| ZERO | Special weight used for cases with exact zero probability. |
| LOWEST_NON_ZERO | Minimal possible non zero weight. |
| UNREACHABLE | Weight to an 'unreachable' block. |
| NORETURN | Weight to a block containing non returning call. |
| UNWIND | Weight to 'unwind' block of an invoke instruction. |
| COLD | Weight to a 'cold' block. Cold blocks are the ones containing calls marked with attribute 'cold'. |
| DEFAULT | Default weight is used in cases when there is no dedicated execution weight set. It is not propagated through the domination line either. |
Definition at line 194 of file BranchProbabilityInfo.cpp.
◆ computeUnlikelySuccessors()
Definition at line 539 of file BranchProbabilityInfo.cpp.
References B(), llvm::cast(), llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldCompareInstOperands(), DL, llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::BranchInst::getCondition(), llvm::BasicBlock::getDataLayout(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), llvm::isa(), llvm::BranchInst::isConditional(), P, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), and llvm::successors().
◆ FPOrdTakenProb()
◆ FPOrdUntakenProb()
◆ FPTakenProb()
◆ FPUntakenProb()
◆ INITIALIZE_PASS_BEGIN()
◆ PtrTakenProb()
◆ PtrUntakenProb()
◆ ZeroTakenProb()
◆ ZeroUntakenProb()
branch Branch Probability Analysis
◆ false
branch Branch Probability false
◆ FCmpTable
Initial value:
{
{FCmpInst::FCMP_ORD, {FPOrdTakenProb, FPOrdUntakenProb}},
{FCmpInst::FCMP_UNO, {FPOrdUntakenProb, FPOrdTakenProb}},
}
static const BranchProbability FPOrdTakenProb(FPH_ORD_WEIGHT, FPH_ORD_WEIGHT+FPH_UNO_WEIGHT)
static const BranchProbability FPOrdUntakenProb(FPH_UNO_WEIGHT, FPH_ORD_WEIGHT+FPH_UNO_WEIGHT)
Floating-Point compares:
Definition at line 187 of file BranchProbabilityInfo.cpp.
◆ FPH_NONTAKEN_WEIGHT
◆ FPH_ORD_WEIGHT
◆ FPH_TAKEN_WEIGHT
◆ FPH_UNO_WEIGHT
This is the probability for an unordered floating point comparison, it means one or two of the operands are NaN.
Usually it is used to test for an exceptional case, so the result is unlikely.
Definition at line 175 of file BranchProbabilityInfo.cpp.
Referenced by FPOrdTakenProb(), and FPOrdUntakenProb().
◆ ICmpWithLibCallTable
Initial value:
{
}
static const BranchProbability ZeroUntakenProb(ZH_NONTAKEN_WEIGHT, ZH_TAKEN_WEIGHT+ZH_NONTAKEN_WEIGHT)
static const BranchProbability ZeroTakenProb(ZH_TAKEN_WEIGHT, ZH_TAKEN_WEIGHT+ZH_NONTAKEN_WEIGHT)
strcmp and similar functions return zero, negative, or positive, if the first string is equal, less, or greater than the second.
We consider it likely that the strings are not equal, so a comparison with zero is probably false, but also a comparison with any other number is also probably false given that what exactly is returned for nonzero values is not specified. Any kind of comparison other than equality we know nothing about.
Definition at line 161 of file BranchProbabilityInfo.cpp.
◆ ICmpWithMinusOneTable
◆ ICmpWithOneTable
◆ ICmpWithZeroTable
◆ LBH_NONTAKEN_WEIGHT
◆ LBH_TAKEN_WEIGHT
◆ PH_NONTAKEN_WEIGHT
◆ PH_TAKEN_WEIGHT
Heuristics and lookup tables for non-loop branches: Pointer Heuristics (PH)
Definition at line 108 of file BranchProbabilityInfo.cpp.
Referenced by PtrTakenProb(), and PtrUntakenProb().
◆ PointerTable
Initial value:
{
{ICmpInst::ICMP_NE, {PtrTakenProb, PtrUntakenProb}},
{ICmpInst::ICMP_EQ, {PtrUntakenProb, PtrTakenProb}},
}
static const BranchProbability PtrTakenProb(PH_TAKEN_WEIGHT, PH_TAKEN_WEIGHT+PH_NONTAKEN_WEIGHT)
static const BranchProbability PtrUntakenProb(PH_NONTAKEN_WEIGHT, PH_TAKEN_WEIGHT+PH_NONTAKEN_WEIGHT)
Pointer comparisons:
Definition at line 119 of file BranchProbabilityInfo.cpp.
◆ PrintBranchProb
| cl::opt< bool > PrintBranchProb("print-bpi", cl::init(false), cl::Hidden, cl::desc("Print the branch probability info.")) ( "print-bpi" , cl::init(false) , cl::Hidden , cl::desc("Print the branch probability info.") ) | static |
|---|
◆ PrintBranchProbFuncName
| cl::opt< std::string > PrintBranchProbFuncName("print-bpi-func-name", cl::Hidden, cl::desc("The option to specify the name of the function " "whose branch probability info is printed.")) ( "print-bpi-func-name" , cl::Hidden , cl::desc("The option to specify the name of the function " "whose branch probability info is printed.") ) | static |
|---|
◆ prob
◆ UR_TAKEN_PROB
Unreachable-terminating branch taken probability.
This is the probability for a branch being taken to a block that terminates (eventually) in unreachable. These are predicted as unlikely as possible. All reachable probability will proportionally share the remaining part.
Definition at line 104 of file BranchProbabilityInfo.cpp.