From 5f21904e7d4e626a569c9e880cf8d67e3c06890a Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Tue, 27 Oct 2020 17:22:30 -0700 Subject: [PATCH] [ThinLTO] Fix .llvmcmd emission llvm::EmbedBitcodeInModule needs (what used to be called) EmbedMarker set, in order to emit .llvmcmd. EmbedMarker is really about embedding the command line, so renamed the parameter accordingly, too. This was not caught at test because the check-prefix was incorrect, but FileCheck does not report that when multiple prefixes are provided. A separate patch will address that. Differential Revision: https://reviews.llvm.org/D90278 --- include/llvm/Bitcode/BitcodeWriter.h | 4 ++-- lib/Bitcode/Writer/BitcodeWriter.cpp | 4 ++-- lib/LTO/LTOBackend.cpp | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/llvm/Bitcode/BitcodeWriter.h b/include/llvm/Bitcode/BitcodeWriter.h index 36c3cb5eb24..7ad2d37a2a3 100644 --- a/include/llvm/Bitcode/BitcodeWriter.h +++ b/include/llvm/Bitcode/BitcodeWriter.h @@ -158,11 +158,11 @@ class raw_ostream; /// pass an empty (default-initialized) MemoryBufferRef, and the serialization /// will be handled by this API. The same behavior happens if the provided Buf /// is not bitcode (i.e. if it's invalid data or even textual LLVM assembly). - /// If EmbedMarker is set, the command line is also exported in + /// If EmbedCmdline is set, the command line is also exported in /// the corresponding section (__LLVM,_cmdline / .llvmcmd) - even if CmdArgs /// were empty. void EmbedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode, - bool EmbedMarker, + bool EmbedCmdline, const std::vector &CmdArgs); } // end namespace llvm diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 02fa1ed6768..7dd38a13b0f 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4834,7 +4834,7 @@ static const char *getSectionNameForCommandline(const Triple &T) { } void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, - bool EmbedBitcode, bool EmbedMarker, + bool EmbedBitcode, bool EmbedCmdline, const std::vector &CmdArgs) { // Save llvm.compiler.used and remove it. SmallVector UsedArray; @@ -4892,7 +4892,7 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, } // Skip if only bitcode needs to be embedded. - if (EmbedMarker) { + if (EmbedCmdline) { // Embed command-line options. ArrayRef CmdData(const_cast(CmdArgs.data()), CmdArgs.size()); diff --git a/lib/LTO/LTOBackend.cpp b/lib/LTO/LTOBackend.cpp index f4da6d87f71..7f437a2af5f 100644 --- a/lib/LTO/LTOBackend.cpp +++ b/lib/LTO/LTOBackend.cpp @@ -373,8 +373,7 @@ bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, dbgs() << "Post-(Thin)LTO merge bitcode embedding was requested, but " "command line arguments are not available"); llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(), - /*EmbedBitcode*/ true, - /*EmbedMarker*/ false, + /*EmbedBitcode*/ true, /*EmbedCmdline*/ true, /*Cmdline*/ CmdArgs); } // FIXME: Plumb the combined index into the new pass manager. @@ -398,7 +397,7 @@ void codegen(const Config &Conf, TargetMachine *TM, AddStreamFn AddStream, if (EmbedBitcode == LTOBitcodeEmbedding::EmbedOptimized) llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(), /*EmbedBitcode*/ true, - /*EmbedMarker*/ false, + /*EmbedCmdline*/ false, /*CmdArgs*/ std::vector()); std::unique_ptr DwoOut;