Go to the documentation of this file.
13 #ifndef LLVM_ANALYSIS_DOTGRAPHTRAITSPASS_H
14 #define LLVM_ANALYSIS_DOTGRAPHTRAITSPASS_H
25 template <
typename Result,
typename GraphT = Result *>
27 static GraphT
getGraph(Result R) {
return &R; }
30 template <
typename GraphT>
36 GraphName +
" for '" +
F.getName() +
"' function");
39 template <
typename AnalysisT,
bool IsSimple,
40 typename GraphT =
typename AnalysisT::Result *,
41 typename AnalysisGraphTraitsT =
42 DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
44 :
PassInfoMixin<DOTGraphTraitsViewer<AnalysisT, IsSimple, GraphT,
45 AnalysisGraphTraitsT>> {
55 const typename AnalysisT::Result &Result) {
60 auto &Result =
FAM.getResult<AnalysisT>(
F);
64 GraphT Graph = AnalysisGraphTraitsT::getGraph(Result);
86 template <
typename GraphT>
89 std::string Filename =
Name.str() +
"." +
F.getName().str() +
".dot";
92 errs() <<
"Writing '" << Filename <<
"'...";
99 GraphName +
" for '" +
F.getName() +
"' function");
101 errs() <<
" error opening file for writing!";
105 template <
typename AnalysisT,
bool IsSimple,
106 typename GraphT =
typename AnalysisT::Result *,
107 typename AnalysisGraphTraitsT =
108 DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
110 :
PassInfoMixin<DOTGraphTraitsPrinter<AnalysisT, IsSimple, GraphT,
111 AnalysisGraphTraitsT>> {
121 const typename AnalysisT::Result &Result) {
126 auto &Result =
FAM.getResult<AnalysisT>(
F);
130 GraphT Graph = AnalysisGraphTraitsT::getGraph(Result);
156 template <
typename AnalysisT,
typename GraphT = AnalysisT *>
161 template <
typename AnalysisT,
bool IsSimple,
typename GraphT = AnalysisT *,
162 typename AnalysisGraphTraitsT =
163 LegacyDefaultAnalysisGraphTraits<AnalysisT, GraphT>>
180 auto &
Analysis = getAnalysis<AnalysisT>();
185 GraphT Graph = AnalysisGraphTraitsT::getGraph(&
Analysis);
200 template <
typename AnalysisT,
bool IsSimple,
typename GraphT = AnalysisT *,
201 typename AnalysisGraphTraitsT =
202 LegacyDefaultAnalysisGraphTraits<AnalysisT, GraphT>>
219 auto &
Analysis = getAnalysis<AnalysisT>();
224 GraphT Graph = AnalysisGraphTraitsT::getGraph(&
Analysis);
239 template <
typename AnalysisT,
bool IsSimple,
typename GraphT = AnalysisT *,
240 typename AnalysisGraphTraitsT =
241 LegacyDefaultAnalysisGraphTraits<AnalysisT, GraphT>>
248 GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
265 template <
typename AnalysisT,
bool IsSimple,
typename GraphT = AnalysisT *,
266 typename AnalysisGraphTraitsT =
267 LegacyDefaultAnalysisGraphTraits<AnalysisT, GraphT>>
274 GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
275 std::string Filename = Name +
".dot";
278 errs() <<
"Writing '" << Filename <<
"'...";
286 errs() <<
" error opening file for writing!";
301 template <
typename GraphT>
303 std::string FileNamePrefix,
bool IsSimple) {
304 std::string Filename = FileNamePrefix +
"." +
F.getName().str() +
".dot";
307 errs() <<
"Writing '" << Filename <<
"'...";
311 std::string Title = GraphName +
" for '" +
F.getName().str() +
"' function";
316 errs() <<
" error opening file for writing!";
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A CRTP mix-in to automatically provide informational APIs needed for passes.
DOTGraphTraitsPrinter(StringRef GraphName)
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
FunctionAnalysisManager FAM
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 runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
virtual bool processFunction(Function &F, const typename AnalysisT::Result &Result)
Return true if this function should be processed.
~DOTGraphTraitsPrinter()
Avoid compiler warning "has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]" in der...
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
Represent the analysis usage information of a pass.
void printGraphForFunction(Function &F, GraphT Graph, StringRef Name, bool IsSimple)
virtual bool processFunction(Function &F, AnalysisT &Analysis)
Return true if this function should be processed.
DOTGraphTraitsViewer(StringRef GraphName)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
Default traits class for extracting a graph from an analysis pass.
DOTGraphTraitsPrinterWrapperPass(StringRef GraphName, char &ID)
DOTGraphTraitsModuleViewerWrapperPass(StringRef GraphName, char &ID)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static std::string getGraphName(const GraphType &)
getGraphName - Return the label for the graph as a whole.
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.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef - Represent a constant reference to a string, i.e.
Default traits class for extracting a graph from an analysis pass.
static GraphT getGraph(AnalysisT *A)
A raw_ostream that writes to a file descriptor.
block Block Frequency Analysis
void WriteDOTGraphToFile(Function &F, GraphT &&Graph, std::string FileNamePrefix, bool IsSimple)
static GraphT getGraph(Result R)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
void setPreservesAll()
Set by analyses that do not transform their input at all.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
virtual bool processFunction(Function &F, AnalysisT &Analysis)
Return true if this function should be processed.
virtual bool processFunction(Function &F, const typename AnalysisT::Result &Result)
Return true if this function should be processed.
DOTGraphTraitsViewerWrapperPass(StringRef GraphName, char &ID)
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
DOTGraphTraitsModulePrinterWrapperPass(StringRef GraphName, char &ID)
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
AnalysisUsage & addRequired()
~DOTGraphTraitsViewer()
Avoid compiler warning "has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]" in der...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void viewGraphForFunction(Function &F, GraphT Graph, StringRef Name, bool IsSimple)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...