1 //===-- BitcodeWriterPass.h - Bitcode writing pass --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file provides a bitcode writing pass.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_BITCODE_BITCODEWRITERPASS_H
16 #define LLVM_BITCODE_BITCODEWRITERPASS_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/IR/PassManager.h"
27 /// Create and return a pass that writes the module to the specified
28 /// ostream. Note that this pass is designed for use with the legacy pass
31 /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
32 /// reproduced when deserialized.
34 /// If \c EmitSummaryIndex, emit the summary index (currently for use in ThinLTO
37 /// If \c EmitModuleHash, compute and emit the module hash in the bitcode
38 /// (currently for use in ThinLTO incremental build).
39 ModulePass *createBitcodeWriterPass(raw_ostream &Str,
40 bool ShouldPreserveUseListOrder = false,
41 bool EmitSummaryIndex = false,
42 bool EmitModuleHash = false);
44 /// Check whether a pass is a BitcodeWriterPass.
45 bool isBitcodeWriterPass(Pass *P);
47 /// Pass for writing a module of IR out to a bitcode file.
49 /// Note that this is intended for use with the new pass manager. To construct
50 /// a pass for the legacy pass manager, use the function above.
51 class BitcodeWriterPass : public PassInfoMixin<BitcodeWriterPass> {
53 bool ShouldPreserveUseListOrder;
54 bool EmitSummaryIndex;
58 /// Construct a bitcode writer pass around a particular output stream.
60 /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
61 /// reproduced when deserialized.
63 /// If \c EmitSummaryIndex, emit the summary index (currently
64 /// for use in ThinLTO optimization).
65 explicit BitcodeWriterPass(raw_ostream &OS,
66 bool ShouldPreserveUseListOrder = false,
67 bool EmitSummaryIndex = false,
68 bool EmitModuleHash = false)
69 : OS(OS), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
70 EmitSummaryIndex(EmitSummaryIndex), EmitModuleHash(EmitModuleHash) {}
72 /// Run the bitcode writer pass, and output the module to the selected
74 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);