Coverage Report

Created: 2019-07-24 05:18

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