27 #define DEBUG_TYPE "block-freq"
38 cl::desc(
"Pop up a window to show a dag displaying how block "
39 "frequencies propagation through the CFG."),
42 "do not display graphs."),
44 "fractional block frequency representation."),
46 "integer fractional block frequency representation."),
98 "never reach this point.");
109 "Block Frequency Analysis",
true,
true)
115 char BlockFrequencyInfo::
ID = 0;
132 LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
135 BFI->doFunction(&F, &BPI, &LI);
150 return BFI ?
BFI->getBlockFreq(BB) : 0;
158 ViewGraph(const_cast<BlockFrequencyInfo *>(
this),
"BlockFrequencyDAGs");
160 errs() <<
"BlockFrequencyInfo::view is only available in debug builds on "
161 "systems with Graphviz or gv!\n";
166 return BFI ?
BFI->getFunction() :
nullptr;
171 return BFI ?
BFI->printBlockFreq(OS, Freq) : OS;
177 return BFI ?
BFI->printBlockFreq(OS, BB) : OS;
181 return BFI ?
BFI->getEntryFreq() : 0;
ValuesClass< DataType > LLVM_END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
block Block Frequency true
std::string getNodeLabel(const BasicBlock *Node, const BlockFrequencyInfo *Graph)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
DOTGraphTraits(bool isSimple=false)
succ_const_iterator ChildIteratorType
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
StringRef getName() const
Return a constant reference to the value's name.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void print(raw_ostream &O, const Module *M) const override
print - Print out the internal state of the pass.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
static ChildIteratorType child_begin(const NodeType *N)
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
static nodes_iterator nodes_begin(const BlockFrequencyInfo *G)
Interval::succ_iterator succ_end(Interval *I)
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
uint64_t getEntryFreq() const
static cl::opt< GVDAGType > ViewBlockFreqPropagationDAG("view-block-freq-propagation-dags", cl::Hidden, cl::desc("Pop up a window to show a dag displaying how block ""frequencies propagation through the CFG."), cl::values(clEnumValN(GVDT_None,"none","do not display graphs."), clEnumValN(GVDT_Fraction,"fraction","display a graph using the ""fractional block frequency representation."), clEnumValN(GVDT_Integer,"integer","display a graph using the raw ""integer fractional block frequency representation."), clEnumValEnd))
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void initializeBlockFrequencyInfoPass(PassRegistry &)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
static ChildIteratorType child_end(const NodeType *N)
~BlockFrequencyInfo() override
void setPreservesAll()
Set by analyses that do not transform their input at all.
INITIALIZE_PASS_BEGIN(BlockFrequencyInfo,"block-freq","Block Frequency Analysis", true, true) INITIALIZE_PASS_END(BlockFrequencyInfo
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
const BasicBlock NodeType
Function::const_iterator nodes_iterator
Analysis pass providing branch probability information.
block Block Frequency Analysis
const Function * getFunction() const
void view() const
Pop up a ghostview window with the current block frequency propagation rendered using dot...
A raw_ostream that writes to an std::string.
This class implements an extremely fast bulk output stream that can only output to a stream...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
The legacy pass manager's analysis pass to compute loop information.
static const NodeType * getEntryNode(const BlockFrequencyInfo *G)
Shared implementation for block frequency analysis.
static std::string getGraphName(const BlockFrequencyInfo *G)
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
static nodes_iterator nodes_end(const BlockFrequencyInfo *G)