]> granicus.if.org Git - llvm/commitdiff
[DomPrinter] Add a way to programmatically dump a dot representation.
authorDavide Italiano <davide@freebsd.org>
Mon, 24 Apr 2017 17:48:44 +0000 (17:48 +0000)
committerDavide Italiano <davide@freebsd.org>
Mon, 24 Apr 2017 17:48:44 +0000 (17:48 +0000)
Differential Revision:  https://reviews.llvm.org/D32145

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301205 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Dominators.h
lib/Analysis/DomPrinter.cpp

index cae03d33a7eedc02bbb68cd83bea14b18b7dfcdc..8f6c85f53efc0ad33f2e3268f49582e2efcc443d 100644 (file)
@@ -157,6 +157,10 @@ public:
   /// This should only be used for debugging as it aborts the program if the
   /// verification fails.
   void verifyDomTree() const;
+
+  // Pop up a GraphViz/gv window with the Dominator Tree rendered using `dot`.
+  void viewGraph(const Twine &Name, const Twine &Title);
+  void viewGraph();
 };
 
 //===-------------------------------------
index 7acfb41500d4ece12593f90401c77df694b84a6d..8abc0e7d0df957fbc74375f109023645a60ce2d0 100644 (file)
@@ -80,6 +80,22 @@ struct DOTGraphTraits<PostDominatorTree*>
 };
 }
 
+void DominatorTree::viewGraph(const Twine &Name, const Twine &Title) {
+#ifndef NDEBUG
+  ViewGraph(this, Name, false, Title);
+#else
+  errs() << "DomTree dump not available, build with DEBUG\n";
+#endif  // NDEBUG
+}
+
+void DominatorTree::viewGraph() {
+#ifndef NDEBUG
+  this->viewGraph("domtree", "Dominator Tree for function");
+#else
+  errs() << "DomTree dump not available, build with DEBUG\n";
+#endif  // NDEBUG
+}
+
 namespace {
 struct DominatorTreeWrapperPassAnalysisGraphTraits {
   static DominatorTree *getGraph(DominatorTreeWrapperPass *DTWP) {