[lld] [llvm] [lld][MachO] Follow-up to use madvise() for threaded file page-in. (PR #157917)

John Holdsworth via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 12:18:40 PDT 2025


================
@@ -505,8 +505,10 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
       // On at least Linux, and possibly on other systems, mmap may return pages
       // from the page cache that are not properly filled with trailing zeroes,
       // if some prior user of the page wrote non-zero bytes. Detect this and
-      // don't use mmap in that case.
-      if (!RequiresNullTerminator || *Result->getBufferEnd() == '\0')
+      // don't use mmap in that case (unless it is object or archive file).
+      if (!RequiresNullTerminator || *Result->getBufferEnd() == '\0' ||
+          StringRef(Filename.str()).ends_with(".o") ||
+          StringRef(Filename.str()).ends_with(".a"))
----------------
johnno1962 wrote:

I know, this version is awful but at least the fix is located close to the change that caused the problem. Have a look at the version before this one which passed in RequiresNullTerminator = false.

https://github.com/llvm/llvm-project/pull/157917


More information about the llvm-commits mailing list