aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Analysis/DOTGraphTraitsPass.h')
-rw-r--r--llvm/include/llvm/Analysis/DOTGraphTraitsPass.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
index 59737744f576..d8021907b5b2 100644
--- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
+++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -181,6 +181,25 @@ private:
std::string Name;
};
+template <typename GraphT>
+void WriteDOTGraphToFile(Function &F, GraphT &&Graph,
+ std::string FileNamePrefix, bool IsSimple) {
+ std::string Filename = FileNamePrefix + "." + F.getName().str() + ".dot";
+ std::error_code EC;
+
+ errs() << "Writing '" << Filename << "'...";
+
+ raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
+ std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
+ std::string Title = GraphName + " for '" + F.getName().str() + "' function";
+
+ if (!EC)
+ WriteGraph(File, Graph, IsSimple, Title);
+ else
+ errs() << " error opening file for writing!";
+ errs() << "\n";
+}
+
} // end namespace llvm
#endif