diff options
author | Mircea Trofin <mtrofin@google.com> | 2020-09-08 17:18:04 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2020-09-10 10:25:00 -0700 |
commit | e543708e5ea7af0ec3ef11d6fe932db507472aa1 (patch) | |
tree | a1c76853fbc2f72dd9da2430a853a7616c629316 /llvm/lib/LTO/LTOBackend.cpp | |
parent | ab1de1fcfb0c53bc768deb8f8bacefad7d378b7b (diff) | |
download | llvm-e543708e5ea7af0ec3ef11d6fe932db507472aa1.zip llvm-e543708e5ea7af0ec3ef11d6fe932db507472aa1.tar.gz llvm-e543708e5ea7af0ec3ef11d6fe932db507472aa1.tar.bz2 |
[NFC][ThinLTO] Let llvm::EmbedBitcodeInModule handle serialization.
llvm::EmbedBitcodeInModule handles serializing the passed-in module, if
the provided MemoryBufferRef is invalid. This is already the path taken
in one of the uses of the API - clang::EmbedBitcode, when called from
BackendConsumer::HandleTranslationUnit - so might as well do the same
here and reduce (by very little) code duplication.
The only difference this patch introduces is that the serialization happens
with ShouldPreserveUseListOrder set to true.
Differential Revision: https://reviews.llvm.org/D87339
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 65d8669..966edcf 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -353,13 +353,7 @@ static cl::opt<bool> EmbedBitcode( static void EmitBitcodeSection(Module &M) { if (!EmbedBitcode) return; - SmallVector<char, 0> Buffer; - raw_svector_ostream OS(Buffer); - WriteBitcodeToFile(M, OS); - - std::unique_ptr<MemoryBuffer> Buf( - new SmallVectorMemoryBuffer(std::move(Buffer))); - llvm::EmbedBitcodeInModule(M, Buf->getMemBufferRef(), /*EmbedBitcode*/ true, + llvm::EmbedBitcodeInModule(M, llvm::MemoryBufferRef(), /*EmbedBitcode*/ true, /*EmbedMarker*/ false, /*CmdArgs*/ nullptr); } |