[lld] [llvm] [LLD][COFF] Prefetch inputs early-on to improve link times (PR #169224)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 07:32:04 PST 2025
================
@@ -1023,6 +1023,30 @@ void mapped_file_region::unmapImpl() {
void mapped_file_region::dontNeedImpl() {}
+void mapped_file_region::willNeedImpl() {
+ HMODULE kernelM = llvm::sys::windows::loadSystemModuleSecure(L"kernel32.dll");
+ if (kernelM) {
+ struct MEMORY_RANGE_ENTRY {
+ PVOID VirtualAddress;
+ SIZE_T NumberOfBytes;
+ };
+
+ // PrefetchVirtualMemory is only available on Windows 8 and later. Since we
+ // still support compilation on Windows 7, we load the function dynamically.
+ typedef BOOL(WINAPI * PrefetchVirtualMemory_t)(
+ HANDLE hProcess, ULONG_PTR NumberOfEntries,
+ _In_reads_(NumberOfEntries) MEMORY_RANGE_ENTRY * VirtualAddresses,
----------------
aganea wrote:
I dropped `_In_reads_`. For `*VirtualAddresses`, clang-format puts it back as above, not sure why.
https://github.com/llvm/llvm-project/pull/169224
More information about the llvm-commits
mailing list