IR, Bitcode: Change bitcode reader to no longer own its memory buffer.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 8 Nov 2016 06:03:43 +0000 (06:03 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 8 Nov 2016 06:03:43 +0000 (06:03 +0000)
commite2dcf7c3a12d5e623048d6e77d5b320dfb553ace
tree6480d5d12f7e5b4be47377fcd50614c9a2f1f434
parent76e4315a0efdaad7cd57d6a1084173c82c2212f4
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

llvm-svn: 286214
13 files changed:
clang/lib/CodeGen/CodeGenAction.cpp
llvm/include/llvm/Bitcode/ReaderWriter.h
llvm/include/llvm/IR/Module.h
llvm/lib/Bitcode/Reader/BitReader.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/IR/Module.cpp
llvm/lib/IRReader/IRReader.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/LTOModule.cpp
llvm/lib/Object/IRObjectFile.cpp
llvm/tools/llvm-dis/llvm-dis.cpp
llvm/unittests/Bitcode/BitReaderTest.cpp