[llvm] r350774 - Don't require a null terminator when loading objects
David Major via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 9 15:36:32 PST 2019
Author: dmajor
Date: Wed Jan 9 15:36:32 2019
New Revision: 350774
URL: http://llvm.org/viewvc/llvm-project?rev=350774&view=rev
Log:
Don't require a null terminator when loading objects
When a null terminator is required and the file size is a multiple of the system page size, MemoryBuffer will prefer pread() over mmap(), which can result in excessive memory usage.
Patch by Mike Hommey!
Differential Revision: https://reviews.llvm.org/D56475
Modified:
llvm/trunk/lib/Object/Binary.cpp
Modified: llvm/trunk/lib/Object/Binary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Binary.cpp?rev=350774&r1=350773&r2=350774&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Binary.cpp (original)
+++ llvm/trunk/lib/Object/Binary.cpp Wed Jan 9 15:36:32 2019
@@ -88,7 +88,8 @@ Expected<std::unique_ptr<Binary>> object
Expected<OwningBinary<Binary>> object::createBinary(StringRef Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
- MemoryBuffer::getFileOrSTDIN(Path);
+ MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
+ /*RequiresNullTerminator=*/false);
if (std::error_code EC = FileOrErr.getError())
return errorCodeToError(EC);
std::unique_ptr<MemoryBuffer> &Buffer = FileOrErr.get();
More information about the llvm-commits
mailing list