[all-commits] [llvm/llvm-project] 890e8c: [Support] Add MemoryBuffer::dontNeedIfMmap
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Dec 30 10:42:41 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 890e8c8f7e9e448a870224068d6b4181d96a293d
https://github.com/llvm/llvm-project/commit/890e8c8f7e9e448a870224068d6b4181d96a293d
Author: Fangrui Song <i at maskray.me>
Date: 2021-12-30 (Thu, 30 Dec 2021)
Changed paths:
M llvm/include/llvm/Support/FileSystem.h
M llvm/include/llvm/Support/MemoryBuffer.h
M llvm/lib/Support/MemoryBuffer.cpp
M llvm/lib/Support/Unix/Path.inc
M llvm/lib/Support/Windows/Path.inc
Log Message:
-----------
[Support] Add MemoryBuffer::dontNeedIfMmap
On *NIX systems, this API calls madvise(MADV_DONTNEED) on read-only file mappings.
It should not be used on a writable buffer.
The API is used to implement ld.lld LTO memory saving trick (D116367).
Note: on read-only file mappings, Linux's MADV_DONTNEED semantics match POSIX
POSIX_MADV_DONTNEED and BSD systems' MADV_DONTNEED.
On Windows, VirtualAllocEx MEM_COMMIT/MEM_RESET have similar semantics
but are unfortunately not drop-in replacements. dontNeedIfMmap is currently a no-op.
Reviewed By: aganea
Differential Revision: https://reviews.llvm.org/D116366
More information about the All-commits
mailing list