blob: a8bb12f3e0184a1c74655c90bcb8b584e096b0ad [file] [log] [blame]
Chris Lattnerac859db2002-10-07 18:38:01 +00001//===- GraphPrinters.cpp - DOT printers for various graph types -----------===//
Misha Brukman3da94ae2005-04-22 00:00:37 +00002//
John Criswell7c0e0222003-10-20 17:47:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner21c62da2007-12-29 20:44:31 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman3da94ae2005-04-22 00:00:37 +00007//
John Criswell7c0e0222003-10-20 17:47:21 +00008//===----------------------------------------------------------------------===//
Chris Lattnerac859db2002-10-07 18:38:01 +00009//
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 Carruth56e13942014-01-13 09:26:24 +000017#include "llvm/IR/Dominators.h"
Chandler Carruthf010c462012-12-04 10:44:52 +000018#include "llvm/Pass.h"
Andrew Tricka125cac2013-01-11 17:28:14 +000019
Chris Lattner27829ec2004-04-12 05:38:01 +000020using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000021
Devang Patel687e03b2008-06-30 17:32:58 +000022//===----------------------------------------------------------------------===//
23// DomInfoPrinter Pass
24//===----------------------------------------------------------------------===//
25
26namespace {
27 class DomInfoPrinter : public FunctionPass {
28 public:
29 static char ID; // Pass identification, replacement for typeid
Owen Anderson90c579d2010-08-06 18:33:48 +000030 DomInfoPrinter() : FunctionPass(ID) {}
Devang Patel687e03b2008-06-30 17:32:58 +000031
Craig Topperc83e68f2014-03-08 08:27:28 +000032 void getAnalysisUsage(AnalysisUsage &AU) const override {
Devang Patel687e03b2008-06-30 17:32:58 +000033 AU.setPreservesAll();
Chandler Carruth7f2eff72014-01-13 13:07:17 +000034 AU.addRequired<DominatorTreeWrapperPass>();
Devang Patel687e03b2008-06-30 17:32:58 +000035 }
36
Craig Topperc83e68f2014-03-08 08:27:28 +000037 bool runOnFunction(Function &F) override {
Matthias Braun88d20752017-01-28 02:02:38 +000038 getAnalysis<DominatorTreeWrapperPass>().print(dbgs());
Devang Patel687e03b2008-06-30 17:32:58 +000039 return false;
40 }
41 };
Devang Patel687e03b2008-06-30 17:32:58 +000042}
Dan Gohmana2a3bbc2010-08-20 00:56:16 +000043
44char DomInfoPrinter::ID = 0;
45static RegisterPass<DomInfoPrinter>
46DIP("print-dom-info", "Dominator Info Printer", true, true);