|
LLVM
10.0.0
|
#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/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/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 <iterator>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "branch-prob" |
Functions | |
| INITIALIZE_PASS_BEGIN (BranchProbabilityInfoWrapperPass, "branch-prob", "Branch Probability Analysis", false, true) INITIALIZE_PASS_END(BranchProbabilityInfoWrapperPass | |
| static void | UpdatePDTWorklist (const BasicBlock *BB, PostDominatorTree *PDT, SmallVectorImpl< const BasicBlock *> &WorkList, SmallPtrSetImpl< const BasicBlock *> &TargetSet) |
| static int | getSCCNum (const BasicBlock *BB, const BranchProbabilityInfo::SccInfo &SccI) |
| static bool | isSCCHeader (const BasicBlock *BB, int SccNum, BranchProbabilityInfo::SccInfo &SccI) |
| static void | computeUnlikelySuccessors (const BasicBlock *BB, Loop *L, SmallPtrSetImpl< const BasicBlock *> &UnlikelyBlocks) |
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 uint32_t | LBH_UNLIKELY_WEIGHT = 62 |
| static const BranchProbability | UR_TAKEN_PROB = BranchProbability::getRaw(1) |
| Unreachable-terminating branch taken probability. More... | |
| static const uint32_t | CC_TAKEN_WEIGHT = 4 |
| Weight for a branch taken going into a cold block. More... | |
| static const uint32_t | CC_NONTAKEN_WEIGHT = 64 |
| Weight for a branch not-taken into a cold block. More... | |
| static const uint32_t | PH_TAKEN_WEIGHT = 20 |
| static const uint32_t | PH_NONTAKEN_WEIGHT = 12 |
| static const uint32_t | ZH_TAKEN_WEIGHT = 20 |
| static const uint32_t | ZH_NONTAKEN_WEIGHT = 12 |
| 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. More... | |
| 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. More... | |
| static const uint32_t | IH_TAKEN_WEIGHT = 1024 * 1024 - 1 |
| Invoke-terminating normal branch taken weight. More... | |
| static const uint32_t | IH_NONTAKEN_WEIGHT = 1 |
| Invoke-terminating normal branch not-taken weight. More... | |
| #define DEBUG_TYPE "branch-prob" |
Definition at line 49 of file BranchProbabilityInfo.cpp.
|
static |
Definition at line 492 of file BranchProbabilityInfo.cpp.
References B, llvm::SmallVectorTemplateCommon< T >::back(), llvm::PHINode::blocks(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dyn_cast(), E, llvm::SmallVectorBase::empty(), llvm::find(), llvm::ConstantExpr::get(), llvm::ConstantExpr::getCompare(), llvm::BranchInst::getCondition(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), getSCCNum(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::BranchInst::isConditional(), llvm::Constant::isOneValue(), isSCCHeader(), llvm::Constant::isZeroValue(), LBH_NONTAKEN_WEIGHT, LBH_TAKEN_WEIGHT, LBH_UNLIKELY_WEIGHT, P, llvm::SmallVectorTemplateBase< T >::pop_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::BranchProbabilityInfo::setEdgeProbability(), llvm::SmallVectorBase::size(), llvm::succ_begin(), and llvm::succ_end().
|
static |
Definition at line 456 of file BranchProbabilityInfo.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and llvm::BranchProbabilityInfo::SccInfo::SccNums.
Referenced by computeUnlikelySuccessors(), and isSCCHeader().
| INITIALIZE_PASS_BEGIN | ( | BranchProbabilityInfoWrapperPass | , |
| "branch-prob" | , | ||
| "Branch Probability Analysis" | , | ||
| false | , | ||
| true | |||
| ) |
|
static |
Definition at line 465 of file BranchProbabilityInfo.cpp.
References llvm::any_of(), assert(), getSCCNum(), llvm::make_range(), llvm::pred_begin(), llvm::pred_end(), and llvm::BranchProbabilityInfo::SccInfo::SccHeaders.
Referenced by computeUnlikelySuccessors().
|
static |
Definition at line 150 of file BranchProbabilityInfo.cpp.
References llvm::all_of(), assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallPtrSetImpl< PtrType >::begin(), llvm::CallingConv::Cold, llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dyn_cast(), llvm::numbers::e, E, llvm::SmallVectorBase::empty(), llvm::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallPtrSetImpl< PtrType >::end(), F(), llvm::APInt::getActiveBits(), llvm::BranchProbability::getBranchProbability(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getDescendants(), llvm::Instruction::getMetadata(), llvm::MDNode::getNumOperands(), llvm::Instruction::getNumSuccessors(), llvm::BranchProbability::getOne(), llvm::MDNode::getOperand(), llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::ConstantInt::getValue(), llvm::BranchProbability::getZero(), llvm::ConstantInt::getZExtValue(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::insert(), llvm::BranchInst::isConditional(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::pred_begin(), llvm::pred_end(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::BranchProbabilityInfo::setEdgeProbability(), llvm::SmallVectorBase::size(), llvm::succ_begin(), llvm::succ_end(), llvm::successors(), and UR_TAKEN_PROB.
| branch Branch Probability Analysis |
Definition at line 64 of file BranchProbabilityInfo.cpp.
Weight for a branch not-taken into a cold block.
This is the weight for a branch not taken toward a block marked cold.
Definition at line 119 of file BranchProbabilityInfo.cpp.
Weight for a branch taken going into a cold block.
This is the weight for a branch taken toward a block marked cold. A block is marked cold if it's postdominated by a block containing a call to a cold function. Cold functions are those marked with attribute 'cold'.
Definition at line 113 of file BranchProbabilityInfo.cpp.
| branch Branch Probability false |
Definition at line 64 of file BranchProbabilityInfo.cpp.
Definition at line 128 of file BranchProbabilityInfo.cpp.
This is the probability for an ordered floating point comparison.
Definition at line 131 of file BranchProbabilityInfo.cpp.
Definition at line 127 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 135 of file BranchProbabilityInfo.cpp.
Invoke-terminating normal branch not-taken weight.
This is the weight for branching to the unwind destination of an invoke instruction. This is essentially never taken.
Definition at line 148 of file BranchProbabilityInfo.cpp.
Invoke-terminating normal branch taken weight.
This is the weight for branching to the normal destination of an invoke instruction. We expect this to happen most of the time. Set the weight to an absurdly high value so that nested loops subsume it.
Definition at line 142 of file BranchProbabilityInfo.cpp.
Definition at line 96 of file BranchProbabilityInfo.cpp.
Referenced by computeUnlikelySuccessors().
Definition at line 95 of file BranchProbabilityInfo.cpp.
Referenced by computeUnlikelySuccessors().
Definition at line 98 of file BranchProbabilityInfo.cpp.
Referenced by computeUnlikelySuccessors().
Definition at line 122 of file BranchProbabilityInfo.cpp.
Definition at line 121 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.")) |
Referenced by llvm::BranchProbabilityInfo::calculate().
| branch prob |
Definition at line 64 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 equally share the remaining part.
Definition at line 105 of file BranchProbabilityInfo.cpp.
Referenced by UpdatePDTWorklist().
Definition at line 125 of file BranchProbabilityInfo.cpp.
Definition at line 124 of file BranchProbabilityInfo.cpp.
1.8.13