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