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."));
47 cl::desc(
"Show heat colors in CFG"));
51 cl::desc(
"Use raw weights for labels. " 52 "Use percentages as default."));
56 cl::desc(
"Show edges labeled with weights"));
60 bool CFGOnly =
false) {
61 std::string Filename =
63 errs() <<
"Writing '" << Filename <<
"'...";
76 errs() <<
" error opening file for writing!";
82 bool CFGOnly =
false) {
88 ViewGraph(&CFGInfo,
"cfg." +
F.getName(), CFGOnly);
99 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
100 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
135 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
136 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
154 "View CFG of function (with no function bodies)",
false,
true)
172 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
173 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
191 "Print CFG of function to 'dot' file",
false,
true)
209 auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
210 auto *
BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
227 "Print CFG of function to 'dot' file (with no function bodies)",
266 return new CFGPrinterLegacyPass();
270 return new CFGOnlyPrinterLegacyPass();
274 auto evaluateBB = [&](
const BasicBlock *Node) {
277 isHiddenBasicBlock[Node] =
282 isHiddenBasicBlock[Node] =
284 return isHiddenBasicBlock[BB];
298 if (isHiddenBasicBlock.find(Node) == isHiddenBasicBlock.end())
299 computeHiddenNodes(Node->getParent());
300 return isHiddenBasicBlock[Node];
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
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."))
A Module instance is used to store all the information related to an LLVM module.
FunctionPass * createCFGPrinterLegacyPassPass()
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
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)
*ViewGraph Emit a dot run run gv on the postscript *then cleanup For use from the debugger *void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
AnalysisUsage & addRequired()
void initializeCFGOnlyPrinterLegacyPassPass(PassRegistry &)
Legacy analysis pass which computes BlockFrequencyInfo.
static cl::opt< bool > HideUnreachablePaths("cfg-hide-unreachable-paths", cl::init(false))
Analysis pass which computes BranchProbabilityInfo.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static cl::opt< bool > ShowEdgeWeight("cfg-weights", cl::init(false), cl::Hidden, cl::desc("Show edges labeled with weights"))
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
Legacy analysis pass which computes BranchProbabilityInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
FunctionPass * createCFGOnlyPrinterLegacyPassPass()
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Instrumentation for Order File
Represent the analysis usage information of a pass.
void setEdgeWeights(bool EdgeWeights)
uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI)
po_iterator< T > po_end(const T &G)
FunctionPass class - This class is used to implement most global optimizations.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool succ_empty(const Instruction *I)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
Analysis pass which computes BlockFrequencyInfo.
static bool isNodeHidden(const void *, const GraphType &)
isNodeHidden - If the function returns true, the given node is not displayed in the graph.
void setPreservesAll()
Set by analyses that do not transform their input at all.
static cl::opt< bool > ShowHeatColors("cfg-heat-colors", cl::init(true), cl::Hidden, cl::desc("Show heat colors in CFG"))
void initializeCFGViewerLegacyPassPass(PassRegistry &)
void initializeCFGPrinterLegacyPassPass(PassRegistry &)
static void writeCFGToDotFile(Function &F, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
Analysis providing branch probability information.
A raw_ostream that writes to a file descriptor.
void setHeatColors(bool ShowHeat)
StringRef getName() const
Return a constant reference to the value's name.
INITIALIZE_PASS(CFGViewerLegacyPass, "view-cfg", "View CFG of function", false, true) PreservedAnalyses CFGViewerPass
succ_range successors(Instruction *I)
static cl::opt< bool > UseRawEdgeWeight("cfg-raw-weights", cl::init(false), cl::Hidden, cl::desc("Use raw weights for labels. " "Use percentages as default."))
This class implements an extremely fast bulk output stream that can only output to a stream.
void setRawEdgeWeights(bool RawWeights)
A container for analyses that lazily runs them and caches their results.
static cl::opt< bool > HideDeoptimizePaths("cfg-hide-deoptimize-paths", cl::init(false))
po_iterator< T > po_begin(const T &G)
void initializeCFGOnlyViewerLegacyPassPass(PassRegistry &)