LLVM  3.7.0
BitcodeWriterPass.cpp
Go to the documentation of this file.
1 //===- BitcodeWriterPass.cpp - Bitcode writing pass -----------------------===//
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 // BitcodeWriterPass implementation.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "llvm/IR/Module.h"
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
19 using namespace llvm;
20 
22  WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder);
23  return PreservedAnalyses::all();
24 }
25 
26 namespace {
27  class WriteBitcodePass : public ModulePass {
28  raw_ostream &OS; // raw_ostream to print on
29  bool ShouldPreserveUseListOrder;
30 
31  public:
32  static char ID; // Pass identification, replacement for typeid
33  explicit WriteBitcodePass(raw_ostream &o, bool ShouldPreserveUseListOrder)
34  : ModulePass(ID), OS(o),
35  ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
36 
37  const char *getPassName() const override { return "Bitcode Writer"; }
38 
39  bool runOnModule(Module &M) override {
40  WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder);
41  return false;
42  }
43  };
44 }
45 
46 char WriteBitcodePass::ID = 0;
47 
49  bool ShouldPreserveUseListOrder) {
50  return new WriteBitcodePass(Str, ShouldPreserveUseListOrder);
51 }
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
This file provides a bitcode writing pass.
ModulePass * createBitcodeWriterPass(raw_ostream &Str, bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified ostream.
An abstract set of preserved analyses following a transformation pass run.
Definition: PassManager.h:69
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false)
Write the specified module to the specified raw output stream.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:91
Module.h This file contains the declarations for the Module class.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:236
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
PreservedAnalyses run(Module &M)
Run the bitcode writer pass, and output the module to the selected output stream. ...
This header defines various interfaces for pass management in LLVM.