Skip to content

Commit 791931a

Browse files
committed
[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 (cherry picked from commit 077d89f)
1 parent 6b8f65a commit 791931a

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
@@ -2658,12 +2658,12 @@ Error DWARFLinker::link() {
26582658
continue;
26592659
}
26602660

2661-
// In a first phase, just read in the debug info and load all clang modules.
2661+
// Clone all the clang modules with requires extracting the DIE units. We
2662+
// don't need the full debug info until the Analyze phase.
26622663
OptContext.CompileUnits.reserve(
26632664
OptContext.File.Dwarf->getNumCompileUnits());
2664-
26652665
for (const auto &CU : OptContext.File.Dwarf->compile_units()) {
2666-
auto CUDie = CU->getUnitDIE(false);
2666+
auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/true);
26672667
if (Options.Verbose) {
26682668
outs() << "Input compilation unit:";
26692669
DIDumpOptions DumpOpts;
@@ -2704,9 +2704,9 @@ Error DWARFLinker::link() {
27042704
return;
27052705

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

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

0 commit comments

Comments
 (0)