LCOV - code coverage report
Current view: top level - lib/CodeGen - MachineFunctionPrinterPass.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 17 17 100.0 %
Date: 2017-09-14 15:23:50 Functions: 10 10 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/Support/Debug.h"
      19             : #include "llvm/Support/raw_ostream.h"
      20             : 
      21             : using namespace llvm;
      22             : 
      23             : namespace {
      24             : /// MachineFunctionPrinterPass - This is a pass to dump the IR of a
      25             : /// MachineFunction.
      26             : ///
      27        2208 : struct MachineFunctionPrinterPass : public MachineFunctionPass {
      28             :   static char ID;
      29             : 
      30             :   raw_ostream &OS;
      31             :   const std::string Banner;
      32             : 
      33          44 :   MachineFunctionPrinterPass() : MachineFunctionPass(ID), OS(dbgs()) { }
      34         714 :   MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
      35        1428 :       : MachineFunctionPass(ID), OS(os), Banner(banner) {}
      36             : 
      37         135 :   StringRef getPassName() const override { return "MachineFunction Printer"; }
      38             : 
      39         736 :   void getAnalysisUsage(AnalysisUsage &AU) const override {
      40         736 :     AU.setPreservesAll();
      41         736 :     MachineFunctionPass::getAnalysisUsage(AU);
      42         736 :   }
      43             : 
      44        1465 :   bool runOnMachineFunction(MachineFunction &MF) override {
      45        1465 :     if (!llvm::isFunctionInPrintList(MF.getName()))
      46             :       return false;
      47        2822 :     OS << "# " << Banner << ":\n";
      48        1411 :     MF.print(OS, getAnalysisIfAvailable<SlotIndexes>());
      49        1411 :     return false;
      50             :   }
      51             : };
      52             : 
      53             : char MachineFunctionPrinterPass::ID = 0;
      54             : }
      55             : 
      56             : char &llvm::MachineFunctionPrinterPassID = MachineFunctionPrinterPass::ID;
      57      151199 : INITIALIZE_PASS(MachineFunctionPrinterPass, "machineinstr-printer",
      58             :                 "Machine Function Printer", false, false)
      59             : 
      60             : namespace llvm {
      61             : /// Returns a newly-created MachineFunction Printer pass. The
      62             : /// default banner is empty.
      63             : ///
      64         714 : MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
      65             :                                                       const std::string &Banner){
      66         714 :   return new MachineFunctionPrinterPass(OS, Banner);
      67             : }
      68             : 
      69             : }

Generated by: LCOV version 1.13