From 5498e18776bcce6a9f016397d42fc27cdfb3ee49 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 8 Nov 2016 06:03:43 +0000 Subject: IR, Bitcode: Change bitcode reader to no longer own its memory buffer. Unique ownership is just one possible ownership pattern for the memory buffer underlying the bitcode reader. In practice, as this patch shows, ownership can often reside at a higher level. With the upcoming change to allow multiple modules in a single bitcode file, it will no longer be appropriate for modules to generally have unique ownership of their memory buffer. The C API exposes the ownership relation via the LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModuleInContext2 functions, so we still need some way for the module to own the memory buffer. This patch does so by adding an owned memory buffer field to Module, and using it in a few other places where it is convenient. Differential Revision: https://reviews.llvm.org/D26384 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286214 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/LTO/LTOBackend.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/LTO/LTOBackend.cpp') diff --git a/lib/LTO/LTOBackend.cpp b/lib/LTO/LTOBackend.cpp index b00c37f7254..0885c0b8484 100644 --- a/lib/LTO/LTOBackend.cpp +++ b/lib/LTO/LTOBackend.cpp @@ -352,8 +352,7 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, auto ModuleLoader = [&](StringRef Identifier) { assert(Mod.getContext().isODRUniquingDebugTypes() && "ODR Type uniquing should be enabled on the context"); - return std::move(getLazyBitcodeModule(MemoryBuffer::getMemBuffer( - ModuleMap[Identifier], false), + return std::move(getLazyBitcodeModule(ModuleMap[Identifier], Mod.getContext(), /*ShouldLazyLoadMetadata=*/true) .get()); -- cgit v1.2.3