Skip to content

Commit ab5871e

Browse files
committed
[DWARFLinker] Release input DWARF after object has been linked (llvm#68376)
dsymutil is using an excessive amount of memory because it's holding on to the DWARF Context, even after it's done processing the corresponding object file. This patch releases the input DWARF after cloning, at which point it is no longer needed. This has always been the intended behavior, though I didn't bisect to figure out when this regressed. When linking swift, this reduces peak (dirty) memory usage from 25 to 15 gigabytes. rdar://111525100 (cherry picked from commit 29a1567)
1 parent e5921e4 commit ab5871e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/include/llvm/DWARFLinker/DWARFLinker.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ class DWARFFile {
276276

277277
/// Helpful address information(list of valid address ranges, relocations).
278278
std::unique_ptr<AddressesMap> Addresses;
279+
280+
/// Unloads object file and corresponding AddressesMap and Dwarf Context.
281+
void unload() {
282+
Addresses.reset();
283+
Dwarf.reset();
284+
}
279285
};
280286

281287
typedef std::map<std::string, std::string> swiftInterfacesMap;
@@ -524,7 +530,8 @@ class DWARFLinker {
524530
/// the debug object.
525531
void clear() {
526532
CompileUnits.clear();
527-
File.Addresses->clear();
533+
ModuleUnits.clear();
534+
File.unload();
528535
}
529536
};
530537

0 commit comments

Comments
 (0)