Chris Lattner | 9126483 | 2002-10-07 18:38:01 +0000 | [diff] [blame] | 1 | //===- GraphPrinters.cpp - DOT printers for various graph types -----------===// |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 345353d | 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 | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 9126483 | 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 | |
Chandler Carruth | 5ad5f15 | 2014-01-13 09:26:24 +0000 | [diff] [blame] | 17 | #include "llvm/IR/Dominators.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 18 | #include "llvm/Pass.h" |
Andrew Trick | 962318f6 | 2013-01-11 17:28:14 +0000 | [diff] [blame] | 19 | |
Chris Lattner | 0a75264 | 2004-04-12 05:38:01 +0000 | [diff] [blame] | 20 | using namespace llvm; |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 21 | |
Devang Patel | 81ea3bb | 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 | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 30 | DomInfoPrinter() : FunctionPass(ID) {} |
Devang Patel | 81ea3bb | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 31 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 32 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
Devang Patel | 81ea3bb | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 33 | AU.setPreservesAll(); |
Chandler Carruth | 7352302 | 2014-01-13 13:07:17 +0000 | [diff] [blame] | 34 | AU.addRequired<DominatorTreeWrapperPass>(); |
Devang Patel | 81ea3bb | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 37 | bool runOnFunction(Function &F) override { |
Chandler Carruth | 7352302 | 2014-01-13 13:07:17 +0000 | [diff] [blame] | 38 | getAnalysis<DominatorTreeWrapperPass>().dump(); |
Devang Patel | 81ea3bb | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 39 | return false; |
| 40 | } |
| 41 | }; |
Devang Patel | 81ea3bb | 2008-06-30 17:32:58 +0000 | [diff] [blame] | 42 | } |
Dan Gohman | 12bb505 | 2010-08-20 00:56:16 +0000 | [diff] [blame] | 43 | |
| 44 | char DomInfoPrinter::ID = 0; |
| 45 | static RegisterPass<DomInfoPrinter> |
| 46 | DIP("print-dom-info", "Dominator Info Printer", true, true); |