Go to the documentation of this file.
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();
145 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
146 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
164 "View CFG of function (with no function bodies)",
false,
true)
186 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
187 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
205 "Print CFG of function to 'dot' file",
false,
true)
227 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
228 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
245 "Print CFG of function to 'dot' file (with no function bodies)",
286 return new CFGPrinterLegacyPass();
290 return new CFGOnlyPrinterLegacyPass();
299 auto evaluateBB = [&](
const BasicBlock *Node) {
302 isOnDeoptOrUnreachablePath[Node] =
307 isOnDeoptOrUnreachablePath[Node] =
309 return isOnDeoptOrUnreachablePath[
BB];
321 uint64_t NodeFreq =
BFI->getBlockFreq(Node).getFrequency();
328 if (isOnDeoptOrUnreachablePath.find(Node) ==
329 isOnDeoptOrUnreachablePath.end())
330 computeDeoptOrUnreachablePaths(Node->getParent());
331 return isOnDeoptOrUnreachablePath[Node];
A set of analyses that are preserved following a run of a transformation pass.
FunctionPass * createCFGOnlyPrinterLegacyPassPass()
INITIALIZE_PASS(CFGViewerLegacyPass, "view-cfg", "View CFG of function", false, true) PreservedAnalyses CFGViewerPass
This is an optimization pass for GlobalISel generic memory operations.
static cl::opt< bool > CFGOnly("dot-mcfg-only", cl::init(false), cl::Hidden, cl::desc("Print only the CFG without blocks body"))
static cl::opt< std::string > CFGDotFilenamePrefix("cfg-dot-filename-prefix", cl::Hidden, cl::desc("The prefix used for the CFG dot file names."))
uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI)
Legacy analysis pass which computes BlockFrequencyInfo.
void setHeatColors(bool ShowHeat)
return AArch64::GPR64RegClass contains(Reg)
static bool isNodeHidden(const void *, const GraphType &)
isNodeHidden - If the function returns true, the given node is not displayed in the graph.
auto successors(const MachineBasicBlock *BB)
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
const BlockFrequencyInfo * getBFI() const
void setEdgeWeights(bool EdgeWeights)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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.
bool succ_empty(const Instruction *I)
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
LLVM Basic Block Representation.
Analysis pass which computes BranchProbabilityInfo.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Legacy analysis pass which computes BranchProbabilityInfo.
void initializeCFGViewerLegacyPassPass(PassRegistry &)
Analysis providing branch probability information.
Represent the analysis usage information of a pass.
void initializeCFGOnlyPrinterLegacyPassPass(PassRegistry &)
This class implements an extremely fast bulk output stream that can only output to a stream.
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Analysis pass which computes BlockFrequencyInfo.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
static cl::opt< bool > HideUnreachablePaths("cfg-hide-unreachable-paths", cl::init(false))
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
static cl::opt< bool > ShowEdgeWeight("cfg-weights", cl::init(false), cl::Hidden, cl::desc("Show edges labeled with weights"))
FunctionPass * createCFGPrinterLegacyPassPass()
initializer< Ty > init(const Ty &Val)
static void writeCFGToDotFile(Function &F, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
A Module instance is used to store all the information related to an LLVM module.
static cl::opt< double > HideColdPaths("cfg-hide-cold-paths", cl::init(0.0), cl::desc("Hide blocks with relative frequency below the given value"))
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
void initializeCFGOnlyViewerLegacyPassPass(PassRegistry &)
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to a file descriptor.
static bool runOnFunction(Function &F, bool PostInlining)
void setPreservesAll()
Set by analyses that do not transform their input at all.
static cl::opt< bool > HideDeoptimizePaths("cfg-hide-deoptimize-paths", cl::init(false))
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
iterator_range< po_iterator< T > > post_order(const T &G)
static cl::opt< bool > ShowHeatColors("cfg-heat-colors", cl::init(true), cl::Hidden, cl::desc("Show heat colors in CFG"))
void initializeCFGPrinterLegacyPassPass(PassRegistry &)
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
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."))
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
void setRawEdgeWeights(bool RawWeights)
static cl::opt< bool > UseRawEdgeWeight("cfg-raw-weights", cl::init(false), cl::Hidden, cl::desc("Use raw weights for labels. " "Use percentages as default."))