[llvm] r301205 - [DomPrinter] Add a way to programmatically dump a dot representation.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 10:48:44 PDT 2017
Author: davide
Date: Mon Apr 24 12:48:44 2017
New Revision: 301205
URL: http://llvm.org/viewvc/llvm-project?rev=301205&view=rev
Log:
[DomPrinter] Add a way to programmatically dump a dot representation.
Differential Revision: https://reviews.llvm.org/D32145
Modified:
llvm/trunk/include/llvm/IR/Dominators.h
llvm/trunk/lib/Analysis/DomPrinter.cpp
Modified: llvm/trunk/include/llvm/IR/Dominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Dominators.h?rev=301205&r1=301204&r2=301205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Dominators.h (original)
+++ llvm/trunk/include/llvm/IR/Dominators.h Mon Apr 24 12:48:44 2017
@@ -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();
};
//===-------------------------------------
Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=301205&r1=301204&r2=301205&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DomPrinter.cpp (original)
+++ llvm/trunk/lib/Analysis/DomPrinter.cpp Mon Apr 24 12:48:44 2017
@@ -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) {
More information about the llvm-commits
mailing list