Chris Lattner | ac859db | 2002-10-07 18:38:01 +0000 | [diff] [blame] | 1 | //===- GraphPrinters.cpp - DOT printers for various graph types -----------===// |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 7c0e022 | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 21c62da | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 7c0e022 | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | ac859db | 2002-10-07 18:38:01 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file defines several printers for various different types of graphs used |
| 11 | // by the LLVM infrastructure. It uses the generic graph interface to convert |
| 12 | // the graph into a .dot graph. These graphs can then be processed with the |
| 13 | // "dot" tool to convert them to postscript or some other suitable format. |
| 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Chris Lattner | 51fbec9 | 2011-04-05 21:43:56 +0000 | [diff] [blame] | 17 | #include "llvm/Analysis/Dominators.h" |
Chandler Carruth | f010c46 | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 18 | #include "llvm/Pass.h" |
Andrew Trick | a125cac | 2013-01-11 17:28:14 +0000 | [diff] [blame] | 19 | |
Chris Lattner | 27829ec | 2004-04-12 05:38:01 +0000 | [diff] [blame] | 20 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 21 | |
Devang Patel | 687e03b | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 22 | //===----------------------------------------------------------------------===// |
| 23 | // DomInfoPrinter Pass |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | |
| 26 | namespace { |
| 27 | class DomInfoPrinter : public FunctionPass { |
| 28 | public: |
| 29 | static char ID; // Pass identification, replacement for typeid |
Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 30 | DomInfoPrinter() : FunctionPass(ID) {} |
Devang Patel | 687e03b | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 31 | |
| 32 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
| 33 | AU.setPreservesAll(); |
| 34 | AU.addRequired<DominatorTree>(); |
Devang Patel | 687e03b | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 35 | |
| 36 | } |
| 37 | |
| 38 | virtual bool runOnFunction(Function &F) { |
Chris Lattner | 9fc5cdf | 2011-01-02 22:09:33 +0000 | [diff] [blame] | 39 | getAnalysis<DominatorTree>().dump(); |
Devang Patel | 687e03b | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 40 | return false; |
| 41 | } |
| 42 | }; |
Devang Patel | 687e03b | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 43 | } |
Dan Gohman | a2a3bbc | 2010-08-20 00:56:16 +0000 | [diff] [blame] | 44 | |
| 45 | char DomInfoPrinter::ID = 0; |
| 46 | static RegisterPass<DomInfoPrinter> |
| 47 | DIP("print-dom-info", "Dominator Info Printer", true, true); |