GraphPrinters.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //===- GraphPrinters.cpp - DOT printers for various graph types -----------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  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. #include "llvm/IR/Dominators.h"
  17. #include "llvm/Pass.h"
  18. using namespace llvm;
  19. //===----------------------------------------------------------------------===//
  20. // DomInfoPrinter Pass
  21. //===----------------------------------------------------------------------===//
  22. namespace {
  23. class DomInfoPrinter : public FunctionPass {
  24. public:
  25. static char ID; // Pass identification, replacement for typeid
  26. DomInfoPrinter() : FunctionPass(ID) {}
  27. void getAnalysisUsage(AnalysisUsage &AU) const override {
  28. AU.setPreservesAll();
  29. AU.addRequired<DominatorTreeWrapperPass>();
  30. }
  31. bool runOnFunction(Function &F) override {
  32. getAnalysis<DominatorTreeWrapperPass>().dump();
  33. return false;
  34. }
  35. };
  36. }
  37. char DomInfoPrinter::ID = 0;
  38. static RegisterPass<DomInfoPrinter>
  39. DIP("print-dom-info", "Dominator Info Printer", true, true);