From: Davide Italiano Date: Mon, 24 Apr 2017 17:48:44 +0000 (+0000) Subject: [DomPrinter] Add a way to programmatically dump a dot representation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c180879c543b8b3c3d97b45f591e231a3b546dfd;p=llvm [DomPrinter] Add a way to programmatically dump a dot representation. Differential Revision: https://reviews.llvm.org/D32145 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301205 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index cae03d33a7e..8f6c85f53ef 100644 --- a/include/llvm/IR/Dominators.h +++ b/include/llvm/IR/Dominators.h @@ -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(); }; //===------------------------------------- diff --git a/lib/Analysis/DomPrinter.cpp b/lib/Analysis/DomPrinter.cpp index 7acfb41500d..8abc0e7d0df 100644 --- a/lib/Analysis/DomPrinter.cpp +++ b/lib/Analysis/DomPrinter.cpp @@ -80,6 +80,22 @@ struct DOTGraphTraits }; } +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) {