LLVM  4.0.0
BitcodeWriterPass.h
Go to the documentation of this file.
1 //===-- BitcodeWriterPass.h - Bitcode writing pass --------------*- C++ -*-===//
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 /// \file
10 ///
11 /// This file provides a bitcode writing pass.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_BITCODE_BITCODEWRITERPASS_H
16 #define LLVM_BITCODE_BITCODEWRITERPASS_H
17 
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/IR/PassManager.h"
20 
21 namespace llvm {
22 class Module;
23 class ModulePass;
24 class raw_ostream;
25 
26 /// \brief Create and return a pass that writes the module to the specified
27 /// ostream. Note that this pass is designed for use with the legacy pass
28 /// manager.
29 ///
30 /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
31 /// reproduced when deserialized.
32 ///
33 /// If \c EmitSummaryIndex, emit the summary index (currently for use in ThinLTO
34 /// optimization).
35 ///
36 /// If \c EmitModuleHash, compute and emit the module hash in the bitcode
37 /// (currently for use in ThinLTO incremental build).
38 ModulePass *createBitcodeWriterPass(raw_ostream &Str,
39  bool ShouldPreserveUseListOrder = false,
40  bool EmitSummaryIndex = false,
41  bool EmitModuleHash = false);
42 
43 /// \brief Pass for writing a module of IR out to a bitcode file.
44 ///
45 /// Note that this is intended for use with the new pass manager. To construct
46 /// a pass for the legacy pass manager, use the function above.
47 class BitcodeWriterPass : public PassInfoMixin<BitcodeWriterPass> {
48  raw_ostream &OS;
49  bool ShouldPreserveUseListOrder;
50  bool EmitSummaryIndex;
51  bool EmitModuleHash;
52 
53 public:
54  /// \brief Construct a bitcode writer pass around a particular output stream.
55  ///
56  /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
57  /// reproduced when deserialized.
58  ///
59  /// If \c EmitSummaryIndex, emit the summary index (currently
60  /// for use in ThinLTO optimization).
62  bool ShouldPreserveUseListOrder = false,
63  bool EmitSummaryIndex = false,
64  bool EmitModuleHash = false)
65  : OS(OS), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
66  EmitSummaryIndex(EmitSummaryIndex), EmitModuleHash(EmitModuleHash) {}
67 
68  /// \brief Run the bitcode writer pass, and output the module to the selected
69  /// output stream.
71 };
72 
73 }
74 
75 #endif
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:311
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
Pass for writing a module of IR out to a bitcode file.
ModulePass * createBitcodeWriterPass(raw_ostream &Str, bool ShouldPreserveUseListOrder=false, bool EmitSummaryIndex=false, bool EmitModuleHash=false)
Create and return a pass that writes the module to the specified ostream.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
Run the bitcode writer pass, and output the module to the selected output stream. ...
BitcodeWriterPass(raw_ostream &OS, bool ShouldPreserveUseListOrder=false, bool EmitSummaryIndex=false, bool EmitModuleHash=false)
Construct a bitcode writer pass around a particular output stream.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.