LLVM 22.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.")) |
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: |
#define DEBUG_TYPE "branch-prob" |
Definition at line 51 of file BranchProbabilityInfo.cpp.
using ProbabilityList = SmallVector<BranchProbability> |
Definition at line 115 of file BranchProbabilityInfo.cpp.
using ProbabilityTable = std::map<CmpInst::Predicate, ProbabilityList> |
Definition at line 116 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 194 of file BranchProbabilityInfo.cpp.
|
static |
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().
|
static |
References FPH_ORD_WEIGHT, and FPH_UNO_WEIGHT.
|
static |
References FPH_ORD_WEIGHT, and FPH_UNO_WEIGHT.
|
static |
References FPH_NONTAKEN_WEIGHT, and FPH_TAKEN_WEIGHT.
|
static |
References FPH_NONTAKEN_WEIGHT, and FPH_TAKEN_WEIGHT.
INITIALIZE_PASS_BEGIN | ( | BranchProbabilityInfoWrapperPass | , |
"branch-prob" | , | ||
"Branch Probability Analysis" | , | ||
false | , | ||
true | ) |
References INITIALIZE_PASS_DEPENDENCY.
|
static |
References PH_NONTAKEN_WEIGHT, and PH_TAKEN_WEIGHT.
|
static |
References PH_NONTAKEN_WEIGHT, and PH_TAKEN_WEIGHT.
|
static |
References ZH_NONTAKEN_WEIGHT, and ZH_TAKEN_WEIGHT.
|
static |
References ZH_NONTAKEN_WEIGHT, and ZH_TAKEN_WEIGHT.
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 187 of file BranchProbabilityInfo.cpp.
Definition at line 168 of file BranchProbabilityInfo.cpp.
Referenced by FPTakenProb(), and FPUntakenProb().
This is the probability for an ordered floating point comparison.
Definition at line 171 of file BranchProbabilityInfo.cpp.
Referenced by FPOrdTakenProb(), and FPOrdUntakenProb().
Definition at line 167 of file BranchProbabilityInfo.cpp.
Referenced by FPTakenProb(), and FPUntakenProb().
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().
|
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 161 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with -1:
Definition at line 141 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with 1:
Definition at line 149 of file BranchProbabilityInfo.cpp.
|
static |
Integer compares with 0:
Definition at line 133 of file BranchProbabilityInfo.cpp.
Definition at line 97 of file BranchProbabilityInfo.cpp.
Definition at line 96 of file BranchProbabilityInfo.cpp.
Definition at line 109 of file BranchProbabilityInfo.cpp.
Referenced by PtrTakenProb(), and PtrUntakenProb().
Heuristics and lookup tables for non-loop branches: Pointer Heuristics (PH)
Definition at line 108 of file BranchProbabilityInfo.cpp.
Referenced by PtrTakenProb(), and PtrUntakenProb().
|
static |
Pointer comparisons:
Definition at line 119 of file BranchProbabilityInfo.cpp.
|
static |
Referenced by llvm::BranchProbabilityInfo::calculate().
|
static |
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 104 of file BranchProbabilityInfo.cpp.
Definition at line 126 of file BranchProbabilityInfo.cpp.
Referenced by ZeroTakenProb(), and ZeroUntakenProb().
Zero Heuristics (ZH)
Definition at line 125 of file BranchProbabilityInfo.cpp.
Referenced by ZeroTakenProb(), and ZeroUntakenProb().