LLVM  6.0.0svn
Macros | Functions | Variables
BranchProbabilityInfo.cpp File Reference
#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/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/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/Pass.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <iterator>
#include <utility>
Include dependency graph for BranchProbabilityInfo.cpp:

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 int getSCCNum (const BasicBlock *BB, const BranchProbabilityInfo::SccInfo &SccI)
 
static bool isSCCHeader (const BasicBlock *BB, int SccNum, BranchProbabilityInfo::SccInfo &SccI)
 

Variables

static cl::opt< boolPrintBranchProb ("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. 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 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...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "branch-prob"

Definition at line 46 of file BranchProbabilityInfo.cpp.

Function Documentation

◆ getSCCNum()

static int getSCCNum ( const BasicBlock BB,
const BranchProbabilityInfo::SccInfo SccI 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( BranchProbabilityInfoWrapperPass  ,
"branch-prob ,
"Branch Probability Analysis ,
false  ,
true   
)

◆ isSCCHeader()

static bool isSCCHeader ( const BasicBlock BB,
int  SccNum,
BranchProbabilityInfo::SccInfo SccI 
)
static

Variable Documentation

◆ Analysis

branch Branch Probability Analysis

Definition at line 61 of file BranchProbabilityInfo.cpp.

◆ CC_NONTAKEN_WEIGHT

const uint32_t CC_NONTAKEN_WEIGHT = 64
static

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 108 of file BranchProbabilityInfo.cpp.

◆ CC_TAKEN_WEIGHT

const uint32_t CC_TAKEN_WEIGHT = 4
static

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 102 of file BranchProbabilityInfo.cpp.

◆ false

branch Branch Probability false

Definition at line 61 of file BranchProbabilityInfo.cpp.

◆ FPH_NONTAKEN_WEIGHT

const uint32_t FPH_NONTAKEN_WEIGHT = 12
static

Definition at line 117 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ FPH_TAKEN_WEIGHT

const uint32_t FPH_TAKEN_WEIGHT = 20
static

Definition at line 116 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ IH_NONTAKEN_WEIGHT

const uint32_t IH_NONTAKEN_WEIGHT = 1
static

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 130 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ IH_TAKEN_WEIGHT

const uint32_t IH_TAKEN_WEIGHT = 1024 * 1024 - 1
static

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 124 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ LBH_NONTAKEN_WEIGHT

const uint32_t LBH_NONTAKEN_WEIGHT = 4
static

Definition at line 87 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ LBH_TAKEN_WEIGHT

const uint32_t LBH_TAKEN_WEIGHT = 124
static

Definition at line 86 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ PH_NONTAKEN_WEIGHT

const uint32_t PH_NONTAKEN_WEIGHT = 12
static

Definition at line 111 of file BranchProbabilityInfo.cpp.

◆ PH_TAKEN_WEIGHT

const uint32_t PH_TAKEN_WEIGHT = 20
static

Definition at line 110 of file BranchProbabilityInfo.cpp.

◆ PrintBranchProb

cl::opt<bool> PrintBranchProb("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."))

◆ prob

branch prob

Definition at line 61 of file BranchProbabilityInfo.cpp.

◆ UR_TAKEN_PROB

const BranchProbability UR_TAKEN_PROB = BranchProbability::getRaw(1)
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 94 of file BranchProbabilityInfo.cpp.

◆ ZH_NONTAKEN_WEIGHT

const uint32_t ZH_NONTAKEN_WEIGHT = 12
static

Definition at line 114 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().

◆ ZH_TAKEN_WEIGHT

const uint32_t ZH_TAKEN_WEIGHT = 20
static

Definition at line 113 of file BranchProbabilityInfo.cpp.

Referenced by isSCCHeader().