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