[PATCH] D40291: [Support] Add WritableMemoryBuffer class

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 10:02:06 PST 2017


A MutableMemoryBuffer need not be backed by mmap.  For example, you could
just allocate some scratch bytes from the heap.  Allowing something like
this to work with the same interface as an mmap is one of the primary
advantages IMO, because it means you don't have to have different code
paths for mmap and malloc.

On Tue, Nov 21, 2017 at 9:58 AM Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> When should a MutableMemoryBuffer (or MemoryBuffer) be used instead of
> mapped_file_region?
>
> My original understanding was that mapped_file_region is for when the
> user needs a real mmap (readwrite maping) or as a MemoryBuffer
> implementation detail.
>
> All other uses should use the MemoryBuffer indirection as it handles
> small files, "volatile" files, etc.
>
> But I see a few direct uses of mapped_file_region in the code
> base. Assuming those uses are a mistake, this patch is probably fine.
>
> > +ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
> > +WritableMemoryBuffer::getFile(const Twine &Filename, int64_t FileSize,
> > +                              bool RequiresNullTerminator, bool
> IsVolatile) {
>
> Do you need RequiresNullTerminator and IsVolatile for rw buffers? If not
> I would suggest leaving those out first and seeing if anyone requests
> them.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171121/2fb318ee/attachment-0001.html>


More information about the llvm-commits mailing list