r286214 - IR, Bitcode: Change bitcode reader to no longer own its memory buffer.

Peter Collingbourne via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 22:03:44 PST 2016


Author: pcc
Date: Tue Nov  8 00:03:43 2016
New Revision: 286214

URL: http://llvm.org/viewvc/llvm-project?rev=286214&view=rev
Log:
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

Modified:
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=286214&r1=286213&r2=286214&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Nov  8 00:03:43 2016
@@ -772,7 +772,7 @@ CodeGenAction::CreateASTConsumer(Compile
       }
 
       ErrorOr<std::unique_ptr<llvm::Module>> ModuleOrErr =
-          getLazyBitcodeModule(std::move(*BCBuf), *VMContext);
+          getOwningLazyBitcodeModule(std::move(*BCBuf), *VMContext);
       if (std::error_code EC = ModuleOrErr.getError()) {
         CI.getDiagnostics().Report(diag::err_cannot_open_file) << LinkBCFile
                                                                << EC.message();




More information about the cfe-commits mailing list