This is an archive of the discontinued LLVM Phabricator instance.

[Dsymutil][Debuginfo][NFC] Reland: Refactor dsymutil to separate DWARF optimizing part. #2.
ClosedPublic

Authored by avl on Dec 23 2019, 6:14 AM.

Details

Summary

This patch relands D71271. The problem with D71271 is that it has cyclic dependency:
CodeGen->AsmPrinter->DebugInfoDWARF->CodeGen. To avoid cyclic dependency this patch
puts implementation for DWARFOptimizer into separate library: lib/DWARFLinker.

Thus the difference between this patch and D71271 is in that DWARFOptimizer renamed into
DWARFLinker and it`s files are put into lib/DWARFLinker.

Diff Detail

Event Timeline

avl created this revision.Dec 23 2019, 6:14 AM

Not sure if this is better/worse off as a subdirectory of lib/CodeGen, rather than as a top level library on its own (lib/DWARFOptimizer). Figured I'd mention it, but mostly leave it up to the other dsymutil folks to make the choices here.

avl added a comment.Dec 24 2019, 2:59 AM

Not sure if this is better/worse off as a subdirectory of lib/CodeGen, rather than as a top level library on its own (lib/DWARFOptimizer). Figured I'd mention it, but mostly leave it up to the other dsymutil folks to make the choices here.

My idea was that DWARFOptimizer does generation task. F.e. AsmPrinter - generates asm and it is under CodeGen. DWARFOptimizer generates optimized DWARF. That is why I put it under CodeGen.
Though if it is better to put it on top level - lib/DWARFOptimizer - I am OK to do this.

In D71839#1795483, @avl wrote:

Not sure if this is better/worse off as a subdirectory of lib/CodeGen, rather than as a top level library on its own (lib/DWARFOptimizer). Figured I'd mention it, but mostly leave it up to the other dsymutil folks to make the choices here.

My idea was that DWARFOptimizer does generation task. F.e. AsmPrinter - generates asm and it is under CodeGen. DWARFOptimizer generates optimized DWARF. That is why I put it under CodeGen.
Though if it is better to put it on top level - lib/DWARFOptimizer - I am OK to do this.

@aprantl @JDevlieghere @probinson any preferences here? If I've got to make the call I'll probably pick lib/DWARFOptimizer or lib/DWARFLinker (probably the latter)

(totally random aside: I Imagine we could have a mode where LLVM's debug info is aware it will be linked with a DWARF aware linker, so it doesn't need to use relocations in some cases (even with DWARFv5, the string relocations (in str_offsets) are still pretty significant & would be nice to skip (as split DWARF manages to skip))

In D71839#1795483, @avl wrote:

Not sure if this is better/worse off as a subdirectory of lib/CodeGen, rather than as a top level library on its own (lib/DWARFOptimizer). Figured I'd mention it, but mostly leave it up to the other dsymutil folks to make the choices here.

My idea was that DWARFOptimizer does generation task. F.e. AsmPrinter - generates asm and it is under CodeGen. DWARFOptimizer generates optimized DWARF. That is why I put it under CodeGen.
Though if it is better to put it on top level - lib/DWARFOptimizer - I am OK to do this.

@aprantl @JDevlieghere @probinson any preferences here? If I've got to make the call I'll probably pick lib/DWARFOptimizer or lib/DWARFLinker (probably the latter)

My personal preference goes to lib/DWARFLinker.

(totally random aside: I Imagine we could have a mode where LLVM's debug info is aware it will be linked with a DWARF aware linker, so it doesn't need to use relocations in some cases (even with DWARFv5, the string relocations (in str_offsets) are still pretty significant & would be nice to skip (as split DWARF manages to skip))

That sounds like an interesting idea indeed!

In D71839#1795483, @avl wrote:

Not sure if this is better/worse off as a subdirectory of lib/CodeGen, rather than as a top level library on its own (lib/DWARFOptimizer). Figured I'd mention it, but mostly leave it up to the other dsymutil folks to make the choices here.

My idea was that DWARFOptimizer does generation task. F.e. AsmPrinter - generates asm and it is under CodeGen. DWARFOptimizer generates optimized DWARF. That is why I put it under CodeGen.
Though if it is better to put it on top level - lib/DWARFOptimizer - I am OK to do this.

@aprantl @JDevlieghere @probinson any preferences here? If I've got to make the call I'll probably pick lib/DWARFOptimizer or lib/DWARFLinker (probably the latter)

My personal preference goes to lib/DWARFLinker.

Let's go with that then - thanks for weighing in!

(totally random aside: I Imagine we could have a mode where LLVM's debug info is aware it will be linked with a DWARF aware linker, so it doesn't need to use relocations in some cases (even with DWARFv5, the string relocations (in str_offsets) are still pretty significant & would be nice to skip (as split DWARF manages to skip))

That sounds like an interesting idea indeed!

(realizing I'm not sure who might implement this - it's not a problem for the Apple/MachO debug info distribution model, which is always DWARF aware and I think already avoids/skips using relocations - and it's not going to be a super high priority for Google, I think, since we use Split DWARF a lot (though switching to DWARFv5 accelerator tables which separate strings from the tables (unlike (gnu_)pubnames/pubtypes) it might be valuable to be able to skip those relocations))

avl added a comment.Jan 3 2020, 3:16 AM
My personal preference goes to lib/DWARFLinker.

Let's go with that then - thanks for weighing in!

Ok. I would make it lib/DWARFLinker. Thanks.

That sounds like an interesting idea indeed!

(realizing I'm not sure who might implement this - it's not a problem for the Apple/MachO debug info distribution model, which is always DWARF aware and I think already avoids/skips using relocations - >and it's not going to be a super high priority for Google, I think, since we use Split DWARF a lot (though switching to DWARFv5 accelerator tables which separate strings from the tables (unlike >(gnu_)pubnames/pubtypes) it might be valuable to be able to skip those relocations))

I could try to implement it when DWARF aware linker would be done.

avl updated this revision to Diff 236428.Jan 6 2020, 11:41 AM

addressed comments:

renamed DWARFOptimizer into DWARFLinker.
put DWARFLinker into separate library llvm/lib/DWARFLinker.
renamed tools/dsymutil/DwarfLinker into tools/dsymutil/DwarfLinkerForBinary.

Unit tests: pass. 61256 tests passed, 0 failed and 736 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

avl marked an inline comment as done.Jan 6 2020, 12:05 PM
avl added inline comments.
llvm/lib/DWARFLinker/LLVMBuild.txt
20

already changed it to:

parent = Libraries

avl updated this revision to Diff 236556.Jan 7 2020, 5:13 AM

apply clang-tidy/clang-format changes.

Unit tests: pass. 61291 tests passed, 0 failed and 736 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

avl edited the summary of this revision. (Show Details)Jan 7 2020, 6:12 AM
JDevlieghere accepted this revision.Jan 7 2020, 12:01 PM
This revision is now accepted and ready to land.Jan 7 2020, 12:01 PM
This revision was automatically updated to reflect the committed changes.