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

          Line data    Source code
       1             : //===- MIRPrintingPass.cpp - Pass that prints out using the MIR format ----===//
       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 implements a pass that prints out the LLVM module using the MIR
      11             : // serialization format.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/CodeGen/MIRPrinter.h"
      16             : 
      17             : #include "llvm/CodeGen/MachineFunctionPass.h"
      18             : #include "llvm/CodeGen/Passes.h"
      19             : #include "llvm/Support/Debug.h"
      20             : #include "llvm/Support/raw_ostream.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : namespace {
      25             : 
      26             : /// This pass prints out the LLVM IR to an output stream using the MIR
      27             : /// serialization format.
      28             : struct MIRPrintingPass : public MachineFunctionPass {
      29             :   static char ID;
      30             :   raw_ostream &OS;
      31             :   std::string MachineFunctions;
      32             : 
      33           0 :   MIRPrintingPass() : MachineFunctionPass(ID), OS(dbgs()) {}
      34        1282 :   MIRPrintingPass(raw_ostream &OS) : MachineFunctionPass(ID), OS(OS) {}
      35             : 
      36           2 :   StringRef getPassName() const override { return "MIR Printing Pass"; }
      37             : 
      38        1282 :   void getAnalysisUsage(AnalysisUsage &AU) const override {
      39             :     AU.setPreservesAll();
      40        1282 :     MachineFunctionPass::getAnalysisUsage(AU);
      41        1282 :   }
      42             : 
      43        4764 :   bool runOnMachineFunction(MachineFunction &MF) override {
      44             :     std::string Str;
      45        4764 :     raw_string_ostream StrOS(Str);
      46        4764 :     printMIR(StrOS, MF);
      47        4764 :     MachineFunctions.append(StrOS.str());
      48        4764 :     return false;
      49             :   }
      50             : 
      51        1119 :   bool doFinalization(Module &M) override {
      52        1119 :     printMIR(OS, M);
      53        1119 :     OS << MachineFunctions;
      54        1119 :     return false;
      55             :   }
      56             : };
      57             : 
      58             : char MIRPrintingPass::ID = 0;
      59             : 
      60             : } // end anonymous namespace
      61             : 
      62             : char &llvm::MIRPrintingPassID = MIRPrintingPass::ID;
      63           0 : INITIALIZE_PASS(MIRPrintingPass, "mir-printer", "MIR Printer", false, false)
      64             : 
      65             : namespace llvm {
      66             : 
      67        1282 : MachineFunctionPass *createPrintMIRPass(raw_ostream &OS) {
      68        1282 :   return new MIRPrintingPass(OS);
      69             : }
      70             : 
      71             : } // end namespace llvm

Generated by: LCOV version 1.13