mirror-llvm-project/bolt/lib/Core
Rafael Auler 5c57064076
[BOLT] Stop materializing .dwo DIE vectors early in the pipeline (#207292)
Summary: preprocessDWODebugInfo() eagerly force-extracted every .dwo
compile unit's DIE tree (getNonSkeletonUnitDIE(false)) very early in
BOLT pipeline, way before DWARFRewriter kicked in. Those vectors then
sit in memory throughout the entire rewrite pipeline, directly
contributing to BOLT's RSS peak. I did a fair amount of digging and
didn't find any reason as to why we need to keep all DIEs of DWO CU
materialized at all, since DWARFRewriter won't even read this vector
(the #197359 concurrency fix did use that, but that is unnecessary). The
problem is that these DIE trees are a massive contribution to RSS when
processing large binaries where we have 10s of K of dwos, storing
complete trees for each processed dwo.

This diff changes the #197359 concurrency fix to not rely on the DIE
sibling/children structure. It parses DWP type units selectively per
compile unit (DIEBuilder::buildDWPTypeUnitsForUnit ->
collectReferencedTypeSignatures) by finding the DW_FORM_ref_sig8
references in a unit's DIEs to decide which type units belong in that
unit's output .dwo. That walk previously used DWARFDie::children(),
which requires the unit's full DIE vector. Here we rewrite the walk to
stream the unit's DIEs one at a time with
DWARFDebugInfoEntry::extractFast (the same technique already used by
DIEBuilder::constructFromUnit and DWARFRewriter::partitionCUs), reading
DW_FORM_ref_sig8 attributes off a single reusable transient entry. The
tree structure is irrelevant -- every DIE in the unit is visited
regardless -- so no DIE vector is
built. collectReferencedTypeSignatures now takes a DWARFUnit& instead of
a DWARFDie.

With the walk self-sufficient:
- preprocessDWODebugInfo() now extracts only the .dwo CU DIE
(getNonSkeletonUnitDIE(true)); nothing reads the full array off it
anymore (constructFromUnit and the signature walk both stream).
- BinaryContext::collectDebugScopeBoundaries() drops its split-DWARF
fast-path, which called DWARFUnit::dies() (= full extraction); DWO units
are now streamed like monolithic ones.

The result is that .dwo DIE vectors are never materialized during BOLT
processing.

Expected to be a ~10% RSS win on large split-dwarf binaries.

Depends on #207291
2026-07-29 11:50:02 -07:00
..
AddressMap.cpp [Support] Remove address-extraction methods from DataExtractor (NFC) (#190519) 2026-04-13 16:44:51 +03:00
BinaryBasicBlock.cpp [BOLT] Remove redundant declarations (NFC) (#166893) 2025-11-07 07:58:24 -08:00
BinaryContext.cpp [BOLT] Stop materializing .dwo DIE vectors early in the pipeline (#207292) 2026-07-29 11:50:02 -07:00
BinaryData.cpp
BinaryEmitter.cpp [BOLT] Fix shifted DWARF inline-scope ranges; track scope boundaries (#207291) 2026-07-14 16:40:05 -07:00
BinaryFunction.cpp [MC][AArch64] Add .cfi_set_ra_state for PAuth_LR (#209949) 2026-07-21 14:22:36 -07:00
BinaryFunctionCallGraph.cpp [bolt] Fix typos discovered by codespell (#124726) 2025-10-14 14:45:40 +02:00
BinaryFunctionProfile.cpp [BOLT][NFC] Disambiguate sample as basic sample (#139350) 2025-05-12 17:15:16 -07:00
BinarySection.cpp [BOLT] Fix pwrite assertion failure via a new safePWrite wrapper (#198569) 2026-07-24 19:55:26 +08:00
CallGraph.cpp [BOLT] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163700) 2025-10-16 13:06:58 -07:00
CallGraphWalker.cpp
CMakeLists.txt [BOLT] Refactor MCInstReference and move it to Core (NFC) (#155846) 2025-09-30 12:46:04 +03:00
DebugData.cpp [BOLT] Stop materializing .dwo DIE vectors early in the pipeline (#207292) 2026-07-29 11:50:02 -07:00
DebugNames.cpp [BOLT][DebugInfo] Add DWARF64 support for BOLT (#206437) 2026-07-24 15:07:52 +08:00
DIEBuilder.cpp [BOLT] Stop materializing .dwo DIE vectors early in the pipeline (#207292) 2026-07-29 11:50:02 -07:00
DynoStats.cpp [BOLT] Remove redundant declarations (NFC) (#166893) 2025-11-07 07:58:24 -08:00
Exceptions.cpp [BOLT] Rename Pointer Auth DWARF rewriter passes (#164622) 2025-12-04 11:29:40 +01:00
FunctionLayout.cpp [BOLT] Avoid n^2 complexity in fixBranches(). NFCI (#160407) 2025-09-23 16:07:54 -07:00
GDBIndex.cpp [BOLT][DebugInfo] Add DWARF64 support for BOLT (#206437) 2026-07-24 15:07:52 +08:00
HashUtilities.cpp [BOLT][AArch64] Speed up ICF pass (#172783) 2025-12-17 21:05:54 -08:00
JumpTable.cpp [BOLT] Change Relocation Type to 32-bit NFCI (#130792) 2025-03-14 18:15:59 +00:00
MCInstUtils.cpp [BOLT] Refactor MCInstReference and move it to Core (NFC) (#155846) 2025-09-30 12:46:04 +03:00
MCPlusBuilder.cpp [MC][TableGen] Make MCRegisterClasses relocation-free (#206753) 2026-07-01 07:40:06 +02:00
ParallelUtilities.cpp [BOLT] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#139403) 2025-05-10 13:39:15 -07:00
Relocation.cpp [BOLT][RISCV] Support the TLS global-dynamic relocation (#209995) 2026-07-21 17:25:01 -07:00