Don't own the buffer in object::Binary.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 19 Aug 2014 18:44:46 +0000 (18:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 19 Aug 2014 18:44:46 +0000 (18:44 +0000)
commit548f2b6e8fc5499fa8c9394fe7d110f50c487802
treefac1350c700e14ca8f9ea779ceb6228caeaff1a0
parent2ac376ba349bd1b4cc5cdc6bde24547e2824f061
Don't own the buffer in object::Binary.

Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216002 91177308-0d34-0410-b5e6-96231b3b80d8
48 files changed:
include/llvm/ExecutionEngine/ExecutionEngine.h
include/llvm/ExecutionEngine/ObjectBuffer.h
include/llvm/ExecutionEngine/ObjectCache.h
include/llvm/LTO/LTOModule.h
include/llvm/Object/Archive.h
include/llvm/Object/Binary.h
include/llvm/Object/COFF.h
include/llvm/Object/ELFObjectFile.h
include/llvm/Object/IRObjectFile.h
include/llvm/Object/MachO.h
include/llvm/Object/MachOUniversal.h
include/llvm/Object/ObjectFile.h
include/llvm/Object/SymbolicFile.h
include/llvm/ProfileData/CoverageMappingReader.h
include/llvm/Support/MemoryBuffer.h
lib/DebugInfo/DWARFUnit.cpp
lib/ExecutionEngine/ExecutionEngine.cpp
lib/ExecutionEngine/MCJIT/MCJIT.cpp
lib/ExecutionEngine/MCJIT/MCJIT.h
lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
lib/LTO/LTOModule.cpp
lib/Object/Archive.cpp
lib/Object/Binary.cpp
lib/Object/COFFObjectFile.cpp
lib/Object/ELFObjectFile.cpp
lib/Object/IRObjectFile.cpp
lib/Object/MachOObjectFile.cpp
lib/Object/MachOUniversal.cpp
lib/Object/Object.cpp
lib/Object/ObjectFile.cpp
lib/Object/SymbolicFile.cpp
lib/ProfileData/CoverageMappingReader.cpp
lib/Support/MemoryBuffer.cpp
tools/lli/lli.cpp
tools/llvm-ar/llvm-ar.cpp
tools/llvm-dwarfdump/llvm-dwarfdump.cpp
tools/llvm-nm/llvm-nm.cpp
tools/llvm-objdump/MachODump.cpp
tools/llvm-objdump/llvm-objdump.cpp
tools/llvm-readobj/llvm-readobj.cpp
tools/llvm-size/llvm-size.cpp
tools/llvm-symbolizer/LLVMSymbolize.cpp
tools/llvm-symbolizer/LLVMSymbolize.h
tools/llvm-vtabledump/llvm-vtabledump.cpp
tools/macho-dump/macho-dump.cpp
tools/obj2yaml/obj2yaml.cpp
unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp