Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
EmbedBitcodePass.cpp
Go to the documentation of this file.
1//===- EmbedBitcodePass.cpp - Pass that embeds the bitcode into a global---===//
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#include "llvm/Transforms/IPO/EmbedBitcodePass.h"
10#include "llvm/Bitcode/BitcodeWriter.h"
11#include "llvm/Bitcode/BitcodeWriterPass.h"
12#include "llvm/IR/PassManager.h"
13#include "llvm/Pass.h"
14#include "llvm/Support/ErrorHandling.h"
15#include "llvm/Support/MemoryBufferRef.h"
16#include "llvm/Support/raw_ostream.h"
17#include "llvm/TargetParser/Triple.h"
18#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
19#include "llvm/Transforms/Utils/ModuleUtils.h"
20
21#include <string>
22
23using namespacellvm;
24
25PreservedAnalysesEmbedBitcodePass::run(Module &M,ModuleAnalysisManager &AM) {
26if (M.getGlobalVariable("llvm.embedded.module",/*AllowInternal=*/true))
27report_fatal_error("Can only embed the module once",
28/*gen_crash_diag=*/false);
29
30TripleT(M.getTargetTriple());
31if (T.getObjectFormat() !=Triple::ELF)
32report_fatal_error(
33"EmbedBitcode pass currently only supports ELF object format",
34/*gen_crash_diag=*/false);
35
36 std::stringData;
37raw_string_ostreamOS(Data);
38if (IsThinLTO)
39ThinLTOBitcodeWriterPass(OS,/*ThinLinkOS=*/nullptr).run(M, AM);
40else
41BitcodeWriterPass(OS,/*ShouldPreserveUseListOrder=*/false, EmitLTOSummary)
42 .run(M, AM);
43
44embedBufferInModule(M,MemoryBufferRef(Data,"ModuleData"),".llvm.lto");
45
46returnPreservedAnalyses::all();
47}
BitcodeWriterPass.h
This file provides a bitcode writing pass.
BitcodeWriter.h
EmbedBitcodePass.h
This file provides a pass which clones the current module and runs the provided pass pipeline on the ...
PassManager.h
This header defines various interfaces for pass management in LLVM.
MemoryBufferRef.h
ModuleUtils.h
Pass.h
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
ThinLTOBitcodeWriter.h
Triple.h
T
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::BitcodeWriterPass
Pass for writing a module of IR out to a bitcode file.
Definition:BitcodeWriterPass.h:41
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::EmbedBitcodePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
Definition:EmbedBitcodePass.cpp:25
llvm::MemoryBufferRef
Definition:MemoryBufferRef.h:22
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
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::ThinLTOBitcodeWriterPass
Definition:ThinLTOBitcodeWriter.h:26
llvm::ThinLTOBitcodeWriterPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition:ThinLTOBitcodeWriter.cpp:580
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Triple::ELF
@ ELF
Definition:Triple.h:312
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition:raw_ostream.h:661
ErrorHandling.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition:Error.cpp:167
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::embedBufferInModule
void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName, Align Alignment=Align(1))
Embed the memory buffer Buf into the module M as a global using the specified section name.
Definition:ModuleUtils.cpp:378
raw_ostream.h

Generated on Fri Jul 18 2025 15:34:50 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp