32 cl::desc(
"The name of a function (or its substring)"
33 " whose CFG is viewed/printed."));
37 cl::desc(
"The prefix used for the CFG dot file names."));
46 "cfg-hide-cold-paths",
cl::init(0.0),
47 cl::desc(
"Hide blocks with relative frequency below the given value"));
51 cl::desc(
"Show heat colors in CFG"));
55 cl::desc(
"Use raw weights for labels. "
56 "Use percentages as default."));
60 cl::desc(
"Show edges labeled with weights"));
65 std::string Filename =
67 errs() <<
"Writing '" << Filename <<
"'...";
80 errs() <<
" error opening file for writing!";
105 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
106 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
122char CFGViewerLegacyPass::ID = 0;
145 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
146 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
162char CFGOnlyViewerLegacyPass::ID = 0;
164 "View CFG of function (with no function bodies)",
false,
true)
186 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
187 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
203char CFGPrinterLegacyPass::ID = 0;
205 "Print CFG of function to 'dot' file",
false,
true)
227 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
228 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
243char CFGOnlyPrinterLegacyPass::ID = 0;
245 "Print CFG of function to 'dot' file (with no function bodies)",
286 return new CFGPrinterLegacyPass();
290 return new CFGOnlyPrinterLegacyPass();
302 isOnDeoptOrUnreachablePath[
Node] =
307 isOnDeoptOrUnreachablePath[
Node] =
309 return isOnDeoptOrUnreachablePath[BB];
320 if (
auto *BFI = CFGInfo->
getBFI()) {
328 if (!isOnDeoptOrUnreachablePath.contains(
Node))
329 computeDeoptOrUnreachablePaths(
Node->getParent());
330 return isOnDeoptOrUnreachablePath[
Node];
static cl::opt< bool > UseRawEdgeWeight("cfg-raw-weights", cl::init(false), cl::Hidden, cl::desc("Use raw weights for labels. " "Use percentages as default."))
static cl::opt< bool > HideUnreachablePaths("cfg-hide-unreachable-paths", cl::init(false))
static void writeCFGToDotFile(Function &F, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
static cl::opt< bool > ShowHeatColors("cfg-heat-colors", cl::init(true), cl::Hidden, cl::desc("Show heat colors in CFG"))
static cl::opt< std::string > CFGDotFilenamePrefix("cfg-dot-filename-prefix", cl::Hidden, cl::desc("The prefix used for the CFG dot file names."))
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
static cl::opt< double > HideColdPaths("cfg-hide-cold-paths", cl::init(0.0), cl::desc("Hide blocks with relative frequency below the given value"))
static cl::opt< bool > HideDeoptimizePaths("cfg-hide-deoptimize-paths", cl::init(false))
static cl::opt< std::string > CFGFuncName("cfg-func-name", cl::Hidden, cl::desc("The name of a function (or its substring)" " whose CFG is viewed/printed."))
static cl::opt< bool > ShowEdgeWeight("cfg-weights", cl::init(false), cl::Hidden, cl::desc("Show edges labeled with weights"))
static cl::opt< bool > CFGOnly("dot-mcfg-only", cl::init(false), cl::Hidden, cl::desc("Print only the CFG without blocks body"))
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM Basic Block Representation.
Analysis pass which computes BlockFrequencyInfo.
Legacy analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Analysis pass which computes BranchProbabilityInfo.
Legacy analysis pass which computes BranchProbabilityInfo.
Analysis providing branch probability information.
void setRawEdgeWeights(bool RawWeights)
void setEdgeWeights(bool EdgeWeights)
const BlockFrequencyInfo * getBFI() const
void setHeatColors(bool ShowHeat)
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
A Module instance is used to store all the information related to an LLVM module.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to a file descriptor.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
This is an optimization pass for GlobalISel generic memory operations.
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool succ_empty(const Instruction *I)
auto successors(const MachineBasicBlock *BB)
iterator_range< po_iterator< T > > post_order(const T &G)
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
FunctionPass * createCFGPrinterLegacyPassPass()
void initializeCFGOnlyPrinterLegacyPassPass(PassRegistry &)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void initializeCFGViewerLegacyPassPass(PassRegistry &)
void initializeCFGPrinterLegacyPassPass(PassRegistry &)
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.
FunctionPass * createCFGOnlyPrinterLegacyPassPass()
void initializeCFGOnlyViewerLegacyPassPass(PassRegistry &)
uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
static bool isNodeHidden(const void *, const GraphType &)
isNodeHidden - If the function returns true, the given node is not displayed in the graph.