[PATCH] D87477: [ThinLTO] Make -lto-embed-bitcode an enum
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 13:33:26 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a2bab5ea2f4: [ThinLTO] Make -lto-embed-bitcode an enum (authored by mtrofin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87477/new/
https://reviews.llvm.org/D87477
Files:
llvm/lib/LTO/LTOBackend.cpp
llvm/test/LTO/X86/embed-bitcode.ll
Index: llvm/test/LTO/X86/embed-bitcode.ll
===================================================================
--- llvm/test/LTO/X86/embed-bitcode.ll
+++ llvm/test/LTO/X86/embed-bitcode.ll
@@ -5,10 +5,10 @@
; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -o %t3 %t1.o %t2.o %t3.o
; RUN: llvm-readelf -S %t3.0 | FileCheck %s --implicit-check-not=.llvmbc
-; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=false -o %t3 %t1.o %t2.o %t3.o
+; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=none -o %t3 %t1.o %t2.o %t3.o
; RUN: llvm-readelf -S %t3.0 | FileCheck %s --implicit-check-not=.llvmbc
-; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode -o %t3 %t1.o %t2.o %t3.o
+; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=optimized -o %t3 %t1.o %t2.o %t3.o
; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
Index: llvm/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -50,6 +50,19 @@
using namespace llvm;
using namespace lto;
+enum class LTOBitcodeEmbedding {
+ DoNotEmbed = 0,
+ EmbedOptimized = 1,
+};
+
+static cl::opt<LTOBitcodeEmbedding> EmbedBitcode(
+ "lto-embed-bitcode", cl::init(LTOBitcodeEmbedding::DoNotEmbed),
+ cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none",
+ "Do not embed"),
+ clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized",
+ "Embed after all optimization passes")),
+ cl::desc("Embed LLVM bitcode in object files produced by LTO"));
+
LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) {
errs() << "failed to open " << Path << ": " << Msg << '\n';
errs().flush();
@@ -346,24 +359,16 @@
return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod);
}
-static cl::opt<bool> EmbedBitcode(
- "lto-embed-bitcode", cl::init(false),
- cl::desc("Embed LLVM bitcode in object files produced by LTO"));
-
-static void EmitBitcodeSection(Module &M) {
- if (!EmbedBitcode)
- return;
- llvm::EmbedBitcodeInModule(M, llvm::MemoryBufferRef(), /*EmbedBitcode*/ true,
- /*EmbedMarker*/ false, /*CmdArgs*/ nullptr);
-}
-
void codegen(const Config &Conf, TargetMachine *TM, AddStreamFn AddStream,
unsigned Task, Module &Mod,
const ModuleSummaryIndex &CombinedIndex) {
if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod))
return;
- EmitBitcodeSection(Mod);
+ if (EmbedBitcode == LTOBitcodeEmbedding::EmbedOptimized)
+ llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(),
+ /*EmbedBitcode*/ true,
+ /*EmbedMarker*/ false, /*CmdArgs*/ nullptr);
std::unique_ptr<ToolOutputFile> DwoOut;
SmallString<1024> DwoFile(Conf.SplitDwarfOutput);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87477.291327.patch
Type: text/x-patch
Size: 3310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/ee52bea5/attachment.bin>
More information about the llvm-commits
mailing list