The primary goal of this refactoring is to separate DWARF optimizing part. So that it could be reused by linker or by any other client. There was a thread on llvm-dev discussing the necessity of such a refactoring:
http://lists.llvm.org/pipermail/llvm-dev/2019-September/135068.html.
The current implementation(DwarfLinker) was separated into four main pieces:
DwarfOptimizer, AddressesMap, DwarfEmitter, DwarfLinker.
DwarfOptimizer - Implements DWARF optimization: starting from root DIEs, scans debug info, and mark dies, which refer to live sections. Creates clones for DIEs, which should be kept. Patches offsets.
AddressesMap - Evaluates relocations and represents live addresses.
DwarfEmitter - Generates .debug_info sections according to specified DIEs or tables.
DwarfLinker - Implements dsymutil functionality.
Testing: it passes "check-all" lit testing. It also passes manual testing, which checks .dSYM bundles for llvm binaries created by dsymutil(by comparing dwarf dump). If there is a better test suite for dsymutil, I would be happy to use it.