GraphPrinters.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include "llvm/IR/Dominators.h"
  16. #include "llvm/Pass.h"
  17. using namespace llvm;
  18. //===----------------------------------------------------------------------===//
  19. // DomInfoPrinter Pass
  20. //===----------------------------------------------------------------------===//
  21. namespace {
  22. class DomInfoPrinter : public FunctionPass {
  23. public:
  24. static char ID; // Pass identification, replacement for typeid
  25. DomInfoPrinter() : FunctionPass(ID) {}
  26. void getAnalysisUsage(AnalysisUsage &AU) const override {
  27. AU.setPreservesAll();
  28. AU.addRequired<DominatorTreeWrapperPass>();
  29. }
  30. bool runOnFunction(Function &F) override {
  31. getAnalysis<DominatorTreeWrapperPass>().print(dbgs());
  32. return false;
  33. }
  34. };
  35. }
  36. char DomInfoPrinter::ID = 0;
  37. static RegisterPass<DomInfoPrinter>
  38. DIP("print-dom-info", "Dominator Info Printer", true, true);