|
LLVM
4.0.0
|
Analysis providing branch probability information. More...
#include <BranchProbabilityInfo.h>
Static Public Member Functions | |
| static BranchProbability | getBranchProbStackProtector (bool IsLikely) |
Analysis providing branch probability information.
This is a function analysis which provides information on the relative probabilities of each "edge" in the function's CFG where such an edge is defined by a pair (PredBlock and an index in the successors). The probability of an edge from one block is always relative to the probabilities of other edges from the block. The probabilites of all edges from a block sum to exactly one (100%). We use a pair (PredBlock and an index in the successors) to uniquely identify an edge, since we can have multiple edges from Src to Dst. As an example, we can have a switch which jumps to Dst with value 0 and value 10.
Definition at line 43 of file BranchProbabilityInfo.h.
|
inline |
Definition at line 45 of file BranchProbabilityInfo.h.
|
inline |
Definition at line 46 of file BranchProbabilityInfo.h.
References calculate().
|
inline |
Definition at line 50 of file BranchProbabilityInfo.h.
Definition at line 663 of file BranchProbabilityInfo.cpp.
References assert(), llvm::dbgs(), DEBUG, F, llvm::Function::getEntryBlock(), llvm::Value::getName(), and llvm::post_order().
Referenced by BranchProbabilityInfo(), llvm::OptimizationRemarkEmitter::OptimizationRemarkEmitter(), and llvm::BranchProbabilityAnalysis::run().
| void BranchProbabilityInfo::eraseBlock | ( | const BasicBlock * | BB | ) |
Forget analysis results for the given basic block.
Definition at line 655 of file BranchProbabilityInfo.cpp.
|
inlinestatic |
Definition at line 114 of file BranchProbabilityInfo.h.
References llvm::BranchProbability::getCompl().
| BranchProbability BranchProbabilityInfo::getEdgeProbability | ( | const BasicBlock * | Src, |
| unsigned | IndexInSuccessors | ||
| ) | const |
Get an edge's probability, relative to other out-edges of the Src.
Get the raw edge probability for the edge.
This routine provides access to the fractional probability between zero (0%) and one (100%) of this edge executing, relative to other edges leaving the 'Src' block. The returned probability is never zero, and can only be one if the source block has only one successor.
If can't find it, return a default probability 1/N where N is the number of successors. Here an edge is specified using PredBlock and an index to the successors.
Definition at line 595 of file BranchProbabilityInfo.cpp.
References I, llvm::succ_begin(), and llvm::succ_end().
Referenced by llvm::CFGMST< Edge, BBInfo >::buildEdges(), llvm::CodeExtractor::extractCodeRegion(), llvm::FastISel::fastEmitBranch(), findUnwindDestinations(), llvm::FastISel::finishCondBranch(), getBranchHint(), getEdgeProbability(), getHotSucc(), isEdgeHot(), and printEdgeProbability().
| BranchProbability BranchProbabilityInfo::getEdgeProbability | ( | const BasicBlock * | Src, |
| const BasicBlock * | Dst | ||
| ) | const |
Get the probability of going from Src to Dst.
Get the raw edge probability calculated for the block pair.
It returns the sum of all probabilities for edges from Src to Dst.
This returns the sum of all raw edge probabilities from Src to Dst.
Definition at line 615 of file BranchProbabilityInfo.cpp.
References E, llvm::BranchProbability::getZero(), I, llvm::succ_begin(), and llvm::succ_end().
| BranchProbability BranchProbabilityInfo::getEdgeProbability | ( | const BasicBlock * | Src, |
| succ_const_iterator | Dst | ||
| ) | const |
Definition at line 607 of file BranchProbabilityInfo.cpp.
References getEdgeProbability(), and llvm::TerminatorInst::SuccIterator< Term, BB >::getSuccessorIndex().
| const BasicBlock * BranchProbabilityInfo::getHotSucc | ( | const BasicBlock * | BB | ) | const |
Retrieve the hot successor of a block if one exists.
Given a basic block, look through its successors and if one exists for which
Definition at line 570 of file BranchProbabilityInfo.cpp.
References E, getEdgeProbability(), llvm::BranchProbability::getZero(), I, llvm::succ_begin(), and llvm::succ_end().
| bool BranchProbabilityInfo::isEdgeHot | ( | const BasicBlock * | Src, |
| const BasicBlock * | Dst | ||
| ) | const |
Test if an edge is hot relative to other out-edges of the Src.
Check whether this edge out of the source block is 'hot'. We define hot as having a relative probability >= 80%.
Definition at line 563 of file BranchProbabilityInfo.cpp.
References getEdgeProbability().
Referenced by printEdgeProbability().
|
inline |
Definition at line 55 of file BranchProbabilityInfo.h.
References releaseMemory().
| void BranchProbabilityInfo::print | ( | raw_ostream & | OS | ) | const |
Definition at line 549 of file BranchProbabilityInfo.cpp.
References assert(), printEdgeProbability(), SI, llvm::succ_begin(), and llvm::succ_end().
Referenced by llvm::BranchProbabilityPrinterPass::run().
| raw_ostream & BranchProbabilityInfo::printEdgeProbability | ( | raw_ostream & | OS, |
| const BasicBlock * | Src, | ||
| const BasicBlock * | Dst | ||
| ) | const |
Print an edge's probability.
Retrieves an edge's probability similarly to
Definition at line 643 of file BranchProbabilityInfo.cpp.
References getEdgeProbability(), llvm::Value::getName(), and isEdgeHot().
Referenced by print().
| void BranchProbabilityInfo::releaseMemory | ( | ) |
Definition at line 545 of file BranchProbabilityInfo.cpp.
Referenced by operator=().
| void BranchProbabilityInfo::setEdgeProbability | ( | const BasicBlock * | Src, |
| unsigned | IndexInSuccessors, | ||
| BranchProbability | Prob | ||
| ) |
Set the raw edge probability for the given edge.
Set the edge probability for a given edge specified by PredBlock and an index to the successors.
This allows a pass to explicitly set the edge probability for an edge. It can be used when updating the CFG to update and preserve the branch probability information. Read the implementation of how these edge probabilities are calculated carefully before using!
Definition at line 633 of file BranchProbabilityInfo.cpp.
References llvm::dbgs(), DEBUG, and llvm::Value::getName().
1.8.6