Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
BitcodeWriterPass.cpp
Go to the documentation of this file.
1//===- BitcodeWriterPass.cpp - Bitcode writing pass -----------------------===//
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// BitcodeWriterPass implementation.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/Bitcode/BitcodeWriterPass.h"
14#include "llvm/Analysis/ModuleSummaryAnalysis.h"
15#include "llvm/Bitcode/BitcodeWriter.h"
16#include "llvm/IR/PassManager.h"
17#include "llvm/InitializePasses.h"
18#include "llvm/Pass.h"
19using namespacellvm;
20
21externboolWriteNewDbgInfoFormatToBitcode;
22
23PreservedAnalysesBitcodeWriterPass::run(Module &M,ModuleAnalysisManager &AM) {
24ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat &&
25WriteNewDbgInfoFormatToBitcode);
26if (M.IsNewDbgInfoFormat)
27 M.removeDebugIntrinsicDeclarations();
28
29constModuleSummaryIndex *Index =
30 EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M))
31 :nullptr;
32WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash);
33
34returnPreservedAnalyses::all();
35}
36
37namespace{
38classWriteBitcodePass :publicModulePass {
39raw_ostream &OS;// raw_ostream to print on
40bool ShouldPreserveUseListOrder;
41
42public:
43staticcharID;// Pass identification, replacement for typeid
44 WriteBitcodePass() :ModulePass(ID),OS(dbgs()) {
45initializeWriteBitcodePassPass(*PassRegistry::getPassRegistry());
46 }
47
48explicit WriteBitcodePass(raw_ostream &o,bool ShouldPreserveUseListOrder)
49 :ModulePass(ID),OS(o),
50 ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
51initializeWriteBitcodePassPass(*PassRegistry::getPassRegistry());
52 }
53
54StringRef getPassName() const override{return"Bitcode Writer"; }
55
56bool runOnModule(Module &M) override{
57ScopedDbgInfoFormatSetter FormatSetter(
58 M,M.IsNewDbgInfoFormat &&WriteNewDbgInfoFormatToBitcode);
59if (M.IsNewDbgInfoFormat)
60M.removeDebugIntrinsicDeclarations();
61
62WriteBitcodeToFile(M,OS, ShouldPreserveUseListOrder,/*Index=*/nullptr,
63/*EmitModuleHash=*/false);
64
65returnfalse;
66 }
67void getAnalysisUsage(AnalysisUsage &AU) const override{
68 AU.setPreservesAll();
69 }
70 };
71}
72
73char WriteBitcodePass::ID = 0;
74INITIALIZE_PASS_BEGIN(WriteBitcodePass,"write-bitcode","Write Bitcode",false,
75true)
76INITIALIZE_PASS_DEPENDENCY(ModuleSummaryIndexWrapperPass)
77INITIALIZE_PASS_END(WriteBitcodePass, "write-bitcode", "WriteBitcode",false,
78true)
79
80ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str,
81bool ShouldPreserveUseListOrder) {
82returnnew WriteBitcodePass(Str, ShouldPreserveUseListOrder);
83}
84
85boolllvm::isBitcodeWriterPass(Pass *P) {
86returnP->getPassID() == (llvm::AnalysisID)&WriteBitcodePass::ID;
87}
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
Bitcode
write Write Bitcode
Definition:BitcodeWriterPass.cpp:77
bitcode
write bitcode
Definition:BitcodeWriterPass.cpp:77
WriteNewDbgInfoFormatToBitcode
bool WriteNewDbgInfoFormatToBitcode
Definition:BasicBlock.cpp:47
BitcodeWriterPass.h
This file provides a bitcode writing pass.
BitcodeWriter.h
PassManager.h
This header defines various interfaces for pass management in LLVM.
InitializePasses.h
WriteNewDbgInfoFormatToBitcode
bool WriteNewDbgInfoFormatToBitcode
Definition:BasicBlock.cpp:47
ModuleSummaryAnalysis.h
This is the interface to build a ModuleSummaryIndex for a module.
P
#define P(N)
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
Pass.h
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition:PassManager.h:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:PassAnalysisSupport.h:130
llvm::BitcodeWriterPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
Run the bitcode writer pass, and output the module to the selected output stream.
Definition:BitcodeWriterPass.cpp:23
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition:Pass.h:251
llvm::ModuleSummaryIndexAnalysis
Analysis pass to provide the ModuleSummaryIndex object.
Definition:ModuleSummaryAnalysis.h:45
llvm::ModuleSummaryIndexWrapperPass
Legacy wrapper pass to provide the ModuleSummaryIndex object.
Definition:ModuleSummaryAnalysis.h:57
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition:ModuleSummaryIndex.h:1345
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition:Pass.h:94
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::ScopedDbgInfoFormatSetter
Used to temporarily set the debug info format of a function, module, or basic block for the duration ...
Definition:DebugProgramInstruction.h:688
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
unsigned
false
Definition:StackSlotColoring.cpp:193
llvm::ARM::ProfileKind::M
@ M
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:CallingConv.h:24
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Write
@ Write
Definition:CodeGenData.h:108
llvm::WriteBitcodeToFile
void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
Definition:BitcodeWriter.cpp:5371
llvm::initializeWriteBitcodePassPass
void initializeWriteBitcodePassPass(PassRegistry &)
llvm::write
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
Definition:DWP.cpp:625
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::createBitcodeWriterPass
ModulePass * createBitcodeWriterPass(raw_ostream &Str, bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified ostream.
Definition:BitcodeWriterPass.cpp:80
llvm::AnalysisID
const void * AnalysisID
Definition:Pass.h:50
llvm::isBitcodeWriterPass
bool isBitcodeWriterPass(Pass *P)
Check whether a pass is a BitcodeWriterPass.
Definition:BitcodeWriterPass.cpp:85

Generated on Fri Jul 18 2025 10:25:26 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp