mirror-llvm-project/lld/COFF
Ben Dunbobbin 914d5a1841
[DTLTO] Overlap temporary file removal (#209423)
Deleting the temporary files produced by the DTLTO pipeline can be
expensive on Windows hosts. For a Clang link (Debug build with
sanitizers and instrumentation) using an optimized toolchain (PGO
non-LTO, llvmorg-22.1.0) on a Windows 11 Pro (Build 26200), AMD Family
25 @ ~4.5 GHz, 16 cores/32 threads, 64 GB RAM machine, the mean duration
of the "Remove DTLTO temporary files" time trace scope was 1267.789 ms
(measured over 10 runs).

This patch performs the deletions on a background thread, allowing them
to overlap with the tail of the link to hide this cost.

This is a re-implementation of the asynchronous cleanup idea from
https://github.com/llvm/llvm-project/pull/186988, which had to be
reverted in https://github.com/llvm/llvm-project/pull/189043 because
cleanup was not guaranteed to complete before LLD invoked
timeTraceProfilerCleanup(). In certain cases timeTraceProfilerCleanup()
was called before temporary file deletion had completed in LLD, which
caused memory leaks that were flagged by sanitizer builds.

Note that the DTLTO implementation has been refactored heavily since
https://github.com/llvm/llvm-project/pull/186988, so this is a
re-implementation along the same lines.

To solve the ordering issue, LLD now calls a hook that defaults to a
no-op, and DTLTO overrides it to drain the background deletion work.
LLD calls this hook before time-trace write/cleanup.
2026-07-21 10:53:46 +01:00
..
CallGraphSort.cpp
CallGraphSort.h
Chunks.cpp [LLD] [COFF] Fix handling of immediates in ARM64_SECREL_HIGH12A (#200060) 2026-05-28 11:03:51 +03:00
Chunks.h [lld] Remove unused DenseMapInfo::getEmptyKey (#201989) 2026-06-06 11:18:02 -07:00
CMakeLists.txt [lld][dtlto] Invert dependency edge from LTO->DTLTO to DTLTO->LTO 2025-12-31 14:10:42 +01:00
COFFLinkerContext.cpp
COFFLinkerContext.h [LLD][COFF] Make /summary work when /debug isn't provided (#157476) 2025-09-09 07:28:24 -04:00
Config.h [LLD] [COFF] Fix crashes for conflicting exports with -export-all-symbols (#190492) 2026-04-07 10:57:52 +03:00
DebugTypes.cpp
DebugTypes.h
DLL.cpp [LLD] [COFF] Fix aarch64 delayimport of sret arguments (#163096) 2025-10-13 23:01:17 +03:00
DLL.h
Driver.cpp [DTLTO] Overlap temporary file removal (#209423) 2026-07-21 10:53:46 +01:00
Driver.h [LLD][COFF] Factor out addObjectFile (NFC) (#206811) 2026-07-02 14:20:52 +02:00
DriverUtils.cpp [lld][llvm-objcopy] Enable Xbox subsystem for PE images. (#191779) 2026-04-14 23:29:14 +01:00
ICF.cpp
ICF.h
InputFiles.cpp [LLD] [COFF] Fix linking directly against an ARM64X DLL without import library (#210311) 2026-07-17 17:30:31 +02:00
InputFiles.h [LLD] [COFF] Fix linking directly against an ARM64X DLL without import library (#210311) 2026-07-17 17:30:31 +02:00
LLDMapFile.cpp
LLDMapFile.h
LTO.cpp [DTLTO] Overlap temporary file removal (#209423) 2026-07-21 10:53:46 +01:00
LTO.h [DTLTO] Overlap temporary file removal (#209423) 2026-07-21 10:53:46 +01:00
MapFile.cpp
MapFile.h
MarkLive.cpp
MarkLive.h
MinGW.cpp [lld][COFF] Use .contains rather than .count for set membership. NFC (#177067) 2026-01-21 17:12:27 -08:00
MinGW.h
Options.td [lld][COFF] Add /discard-section option to discard input sections by name (#189542) 2026-04-04 20:26:12 +08:00
PDB.cpp [LLD][COFF] Make /summary work when /debug isn't provided (#157476) 2025-09-09 07:28:24 -04:00
PDB.h [LLD][COFF] Make /summary work when /debug isn't provided (#157476) 2025-09-09 07:28:24 -04:00
README.md
Symbols.cpp
Symbols.h [LLD][COFF] Deduplicate common chunks when linking COFF files. (#162553) 2025-10-24 16:07:49 -04:00
SymbolTable.cpp [DTLTO] Overlap temporary file removal (#209423) 2026-07-21 10:53:46 +01:00
SymbolTable.h [DTLTO] Overlap temporary file removal (#209423) 2026-07-21 10:53:46 +01:00
TypeMerger.h
Writer.cpp [LLD][COFF] Prevent merging .bss into shared sections (#202817) 2026-07-01 12:59:18 +02:00
Writer.h

See docs/NewLLD.rst