[PATCH] [Support] Add MemoryBuffer::getFileSlice()

kledzik at apple.com kledzik at apple.com
Thu Sep 25 16:25:59 PDT 2014


There are two issues:

1) Apple has hundreds of dylibs and they are usually fat.  A 32-bit process could run out of address space if it had to map the entirety of every fat file.  

2) The lld the structure is that the InputGraphNode maps the file, then some Reader claims it and parses it.  The parsing may or may not have pointers into the original buffer.  If it does, the created lld::File object takes ownership of the buffer as part of parsing.  If not, the ownership stays with the InputGraphNode which quickly frees it.  In that model, you cannot pass down a StringRef because that cannot transfer ownership of the original MemoryBuffer.   If MemoryBuffer had getFileSlice(), then the darwin InputGraphNode can check if the file is fat, and if so, only map the relevant slice.  That would solve the address space issue and fit into the lld MemoryBuffer ownership model.

http://reviews.llvm.org/D5423






More information about the llvm-commits mailing list