LCOV - code coverage report
Current view: top level - lib/CodeGen - MachineFunctionPrinterPass.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 15 15 100.0 %
Date: 2018-10-20 13:21:21 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- MachineFunctionPrinterPass.cpp ------------------------------------===//
       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             : // MachineFunctionPrinterPass implementation.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/CodeGen/MachineFunction.h"
      15             : #include "llvm/CodeGen/MachineFunctionPass.h"
      16             : #include "llvm/CodeGen/Passes.h"
      17             : #include "llvm/CodeGen/SlotIndexes.h"
      18             : #include "llvm/IR/IRPrintingPasses.h"
      19             : #include "llvm/Support/Debug.h"
      20             : #include "llvm/Support/raw_ostream.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : namespace {
      25             : /// MachineFunctionPrinterPass - This is a pass to dump the IR of a
      26             : /// MachineFunction.
      27             : ///
      28             : struct MachineFunctionPrinterPass : public MachineFunctionPass {
      29             :   static char ID;
      30             : 
      31             :   raw_ostream &OS;
      32             :   const std::string Banner;
      33             : 
      34          21 :   MachineFunctionPrinterPass() : MachineFunctionPass(ID), OS(dbgs()) { }
      35        1006 :   MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
      36        1006 :       : MachineFunctionPass(ID), OS(os), Banner(banner) {}
      37             : 
      38         158 :   StringRef getPassName() const override { return "MachineFunction Printer"; }
      39             : 
      40        1027 :   void getAnalysisUsage(AnalysisUsage &AU) const override {
      41             :     AU.setPreservesAll();
      42             :     AU.addUsedIfAvailable<SlotIndexes>();
      43        1027 :     MachineFunctionPass::getAnalysisUsage(AU);
      44        1027 :   }
      45             : 
      46        1900 :   bool runOnMachineFunction(MachineFunction &MF) override {
      47        1900 :     if (!llvm::isFunctionInPrintList(MF.getName()))
      48             :       return false;
      49        3670 :     OS << "# " << Banner << ":\n";
      50        1835 :     MF.print(OS, getAnalysisIfAvailable<SlotIndexes>());
      51        1835 :     return false;
      52             :   }
      53             : };
      54             : 
      55             : char MachineFunctionPrinterPass::ID = 0;
      56             : }
      57             : 
      58             : char &llvm::MachineFunctionPrinterPassID = MachineFunctionPrinterPass::ID;
      59       85147 : INITIALIZE_PASS(MachineFunctionPrinterPass, "machineinstr-printer",
      60             :                 "Machine Function Printer", false, false)
      61             : 
      62             : namespace llvm {
      63             : /// Returns a newly-created MachineFunction Printer pass. The
      64             : /// default banner is empty.
      65             : ///
      66        1006 : MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
      67             :                                                       const std::string &Banner){
      68        1006 :   return new MachineFunctionPrinterPass(OS, Banner);
      69             : }
      70             : 
      71             : }

Generated by: LCOV version 1.13