Skip to content

Commit 077d89f

Browse files
authored
[DWARFLinker] Only extract unit DIEs when cloning clang modules (llvm#69495)
Reduce memory usage by only extract unit DIEs when cloning clang modules. We don't need the full debug info yet at this stage. This reduces peak memory usage of dsymutil when linking the swift driver by multiple gigabytes. rdar://117156180
1 parent b8b7c3b commit 077d89f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/DWARFLinker/DWARFLinker.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,12 +2682,12 @@ Error DWARFLinker::link() {
26822682
continue;
26832683
}
26842684

2685-
// In a first phase, just read in the debug info and load all clang modules.
2685+
// Clone all the clang modules with requires extracting the DIE units. We
2686+
// don't need the full debug info until the Analyze phase.
26862687
OptContext.CompileUnits.reserve(
26872688
OptContext.File.Dwarf->getNumCompileUnits());
2688-
26892689
for (const auto &CU : OptContext.File.Dwarf->compile_units()) {
2690-
auto CUDie = CU->getUnitDIE(false);
2690+
auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/true);
26912691
if (Options.Verbose) {
26922692
outs() << "Input compilation unit:";
26932693
DIDumpOptions DumpOpts;
@@ -2728,9 +2728,9 @@ Error DWARFLinker::link() {
27282728
return;
27292729

27302730
for (const auto &CU : Context.File.Dwarf->compile_units()) {
2731-
// The !isClangModuleRef condition effectively skips over fully resolved
2732-
// skeleton units.
2733-
auto CUDie = CU->getUnitDIE();
2731+
// Previously we only extracted the unit DIEs. We need the full debug info
2732+
// now.
2733+
auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
27342734
std::string PCMFile = getPCMFile(CUDie, Options.ObjectPrefixMap);
27352735

27362736
if (!CUDie || LLVM_UNLIKELY(Options.Update) ||

0 commit comments

Comments
 (0)