27 #define DEBUG_TYPE "block-freq"
39 cl::desc(
"Pop up a window to show a dag displaying how machine block "
40 "frequencies propagate through the CFG."),
43 "do not display graphs."),
45 "fractional block frequency representation."),
47 "integer fractional block frequency representation."),
105 "never reach this point.");
117 "Machine Block Frequency Analysis",
true,
true)
123 char MachineBlockFrequencyInfo::
ID = 0;
126 MachineBlockFrequencyInfo::
142 getAnalysis<MachineBranchProbabilityInfo>();
146 MBFI->doFunction(&F, &MBPI, &MLI);
162 ViewGraph(const_cast<MachineBlockFrequencyInfo *>(
this),
163 "MachineBlockFrequencyDAGs");
165 errs() <<
"MachineBlockFrequencyInfo::view is only available in debug builds "
166 "on systems with Graphviz or gv!\n";
172 return MBFI ? MBFI->getBlockFreq(MBB) : 0;
176 return MBFI ? MBFI->getFunction() :
nullptr;
182 return MBFI ? MBFI->printBlockFreq(OS, Freq) : OS;
188 return MBFI ? MBFI->printBlockFreq(OS, MBB) : OS;
192 return MBFI ? MBFI->getEntryFreq() : 0;
ValuesClass< DataType > LLVM_END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const MachineBasicBlock NodeType
machine block Machine Block Frequency true
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
void view() const
Pop up a ghostview window with the current block frequency propagation rendered using dot...
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
std::string str() const
str - Get the contents as an std::string.
static ChildIteratorType child_end(const NodeType *N)
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
uint64_t getEntryFreq() const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineBlockFrequencyInfo *Graph)
machine block Machine Block Frequency Analysis
DOTGraphTraits(bool isSimple=false)
~MachineBlockFrequencyInfo() override
COFF::MachineTypes Machine
static nodes_iterator nodes_begin(const MachineBlockFrequencyInfo *G)
static cl::opt< GVDAGType > ViewMachineBlockFreqPropagationDAG("view-machine-block-freq-propagation-dags", cl::Hidden, cl::desc("Pop up a window to show a dag displaying how machine block ""frequencies propagate 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 - Subclasses that override getAnalysisUsage must call this.
MachineFunction::const_iterator nodes_iterator
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
Represent the analysis usage information of a pass.
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.
succ_iterator succ_begin()
void initializeMachineBlockFrequencyInfoPass(PassRegistry &)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
MachineBasicBlock::const_succ_iterator ChildIteratorType
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef getName() const
getName - Return the name of the corresponding LLVM basic block, or "(null)".
void setPreservesAll()
Set by analyses that do not transform their input at all.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static const NodeType * getEntryNode(const MachineBlockFrequencyInfo *G)
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
static nodes_iterator nodes_end(const MachineBlockFrequencyInfo *G)
static ChildIteratorType child_begin(const NodeType *N)
INITIALIZE_PASS_BEGIN(MachineBlockFrequencyInfo,"machine-block-freq","Machine Block Frequency Analysis", true, true) INITIALIZE_PASS_END(MachineBlockFrequencyInfo
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
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 ...
Shared implementation for block frequency analysis.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static std::string getGraphName(const MachineBlockFrequencyInfo *G)
const MachineFunction * getFunction() const