1*0b57cec5SDimitry Andric //===- GraphPrinters.cpp - DOT printers for various graph types -----------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file defines several printers for various different types of graphs used 10*0b57cec5SDimitry Andric // by the LLVM infrastructure. It uses the generic graph interface to convert 11*0b57cec5SDimitry Andric // the graph into a .dot graph. These graphs can then be processed with the 12*0b57cec5SDimitry Andric // "dot" tool to convert them to postscript or some other suitable format. 13*0b57cec5SDimitry Andric // 14*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #include "llvm/IR/Dominators.h" 17*0b57cec5SDimitry Andric #include "llvm/Pass.h" 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric using namespace llvm; 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 22*0b57cec5SDimitry Andric // DomInfoPrinter Pass 23*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric namespace { 26*0b57cec5SDimitry Andric class DomInfoPrinter : public FunctionPass { 27*0b57cec5SDimitry Andric public: 28*0b57cec5SDimitry Andric static char ID; // Pass identification, replacement for typeid DomInfoPrinter()29*0b57cec5SDimitry Andric DomInfoPrinter() : FunctionPass(ID) {} 30*0b57cec5SDimitry Andric getAnalysisUsage(AnalysisUsage & AU) const31*0b57cec5SDimitry Andric void getAnalysisUsage(AnalysisUsage &AU) const override { 32*0b57cec5SDimitry Andric AU.setPreservesAll(); 33*0b57cec5SDimitry Andric AU.addRequired<DominatorTreeWrapperPass>(); 34*0b57cec5SDimitry Andric } 35*0b57cec5SDimitry Andric runOnFunction(Function & F)36*0b57cec5SDimitry Andric bool runOnFunction(Function &F) override { 37*0b57cec5SDimitry Andric getAnalysis<DominatorTreeWrapperPass>().print(dbgs()); 38*0b57cec5SDimitry Andric return false; 39*0b57cec5SDimitry Andric } 40*0b57cec5SDimitry Andric }; 41*0b57cec5SDimitry Andric } 42*0b57cec5SDimitry Andric 43*0b57cec5SDimitry Andric char DomInfoPrinter::ID = 0; 44*0b57cec5SDimitry Andric static RegisterPass<DomInfoPrinter> 45*0b57cec5SDimitry Andric DIP("print-dom-info", "Dominator Info Printer", true, true); 46