Skip to content

Commit 1b9b139

Browse files
committed
Revert "Alternative solution to performance regression."
This reverts commit 884b771.
1 parent 884b771 commit 1b9b139

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
217217
if (entry != cachedReads.end())
218218
return entry->second;
219219

220-
ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr = MemoryBuffer::getFile(path);
220+
ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr =
221+
MemoryBuffer::getFile(path, false, /*RequiresNullTerminator*/ false);
221222
if (std::error_code ec = mbOrErr.getError()) {
222223
error("cannot open " + path + ": " + ec.message());
223224
return std::nullopt;

llvm/lib/Object/Archive.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,8 @@ Expected<StringRef> Archive::Child::getBuffer() const {
584584
if (!FullNameOrErr)
585585
return FullNameOrErr.takeError();
586586
const std::string &FullName = *FullNameOrErr;
587-
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FullName);
587+
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf =
588+
MemoryBuffer::getFile(FullName, false, /*RequiresNullTerminator*/ false);
588589
if (std::error_code EC = Buf.getError())
589590
return errorCodeToError(EC);
590591
Parent->ThinBuffers.push_back(std::move(*Buf));

llvm/lib/Support/MemoryBuffer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,8 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
505505
// On at least Linux, and possibly on other systems, mmap may return pages
506506
// from the page cache that are not properly filled with trailing zeroes,
507507
// if some prior user of the page wrote non-zero bytes. Detect this and
508-
// don't use mmap in that case (unless it is object or archive file).
509-
if (!RequiresNullTerminator || *Result->getBufferEnd() == '\0' ||
510-
StringRef(Filename.str()).ends_with(".o") ||
511-
StringRef(Filename.str()).ends_with(".a"))
508+
// don't use mmap in that case.
509+
if (!RequiresNullTerminator || *Result->getBufferEnd() == '\0')
512510
return std::move(Result);
513511
}
514512
}

0 commit comments

Comments
 (0)