LLVM 20.0.0git
|
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <map>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "branch-prob" |
Typedefs | |
using | ProbabilityList = SmallVector< BranchProbability > |
using | ProbabilityTable = std::map< CmpInst::Predicate, ProbabilityList > |
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.")) |
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: | |
#define DEBUG_TYPE "branch-prob" |
Definition at line 51 of file BranchProbabilityInfo.cpp.
using ProbabilityList = SmallVector<BranchProbability> |
Definition at line 118 of file BranchProbabilityInfo.cpp.
using ProbabilityTable = std::map<CmpInst::Predicate, ProbabilityList> |
Definition at line 119 of file BranchProbabilityInfo.cpp.
|
strong |
Set of dedicated "absolute" execution weights for a block.
These weights are meaningful relative to each other and their derivatives only.
Definition at line 197 of file BranchProbabilityInfo.cpp.
|
static |
Definition at line 542 of file BranchProbabilityInfo.cpp.
References B, llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldCompareInstOperands(), DL, llvm::SmallVectorBase< Size_T >::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::BranchInst::isConditional(), P, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), and llvm::successors().
|
static |
|
static |
|
static |
|
static |
INITIALIZE_PASS_BEGIN | ( | BranchProbabilityInfoWrapperPass | , |
"branch-prob" | , | ||
"Branch Probability Analysis" | , | ||
false | , | ||
true | |||
) |
|
static |
|
static |
|
static |
|
static |
branch Branch Probability Analysis |
Definition at line 69 of file BranchProbabilityInfo.cpp.
branch Branch Probability false |
Definition at line 69 of file BranchProbabilityInfo.cpp.
|
static |
Floating-Point compares:
Definition at line 190 of file BranchProbabilityInfo.cpp.
Definition at line 171 of file BranchProbabilityInfo.cpp.
This is the probability for an ordered floating point comparison.
Definition at line 174 of file BranchProbabilityInfo.cpp.
Definition at line 170 of file BranchProbabilityInfo.cpp.
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 178 of file BranchProbabilityInfo.cpp.
|
static |
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 164 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with -1:
Definition at line 144 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with 1:
Definition at line 152 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with 0:
Definition at line 136 of file BranchProbabilityInfo.cpp.
Definition at line 100 of file BranchProbabilityInfo.cpp.
Definition at line 99 of file BranchProbabilityInfo.cpp.
Definition at line 112 of file BranchProbabilityInfo.cpp.
Heuristics and lookup tables for non-loop branches: Pointer Heuristics (PH)
Definition at line 111 of file BranchProbabilityInfo.cpp.
|
static |
Pointer comparisons:
Definition at line 122 of file BranchProbabilityInfo.cpp.
|
static |
Referenced by llvm::BranchProbabilityInfo::calculate().
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.") | |||
) |
Referenced by llvm::BranchProbabilityInfo::calculate().
branch prob |
Definition at line 68 of file BranchProbabilityInfo.cpp.
|
static |
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 107 of file BranchProbabilityInfo.cpp.
Definition at line 129 of file BranchProbabilityInfo.cpp.
Zero Heuristics (ZH)
Definition at line 128 of file BranchProbabilityInfo.cpp.