This is an archive of the discontinued LLVM Phabricator instance.

Module flag to suppress the DWARF entries DW_AT_MIPS_linkage_name and DW_AT_linkage_name.
AbandonedPublic

Authored by wolfgangp on Sep 26 2014, 2:41 PM.

Details

Reviewers
dblaikie
echristo
Summary

I’d like to add a way to suppress DW_AT_MIPS_linkage_name and DW_AT_linkage_name entries in DWARF. Measurements of debug info size (specifically, the .debug_str section) have shown that some decent reductions are to be had by not emitting these entries, benefiting DWARF consumers that do not use them.

Diff Detail

Event Timeline

wolfgangp updated this revision to Diff 14137.Sep 26 2014, 2:41 PM
wolfgangp retitled this revision from to Option to suppress the DWARF entries DW_AT_MIPS_linkage_name and DW_AT_linkage_name..
wolfgangp updated this object.
wolfgangp edited the test plan for this revision. (Show Details)
wolfgangp added a subscriber: Unknown Object (MLST).
dblaikie added inline comments.
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
45

I believe we're trying to move away from surfacing command line flags in this way for user-facing features. (see Chris Bieneman's work).

I'm not sure what the right answner is these days - this could be a flag on the compile_unit metadata - in which case it could be properly respected under LTO (if one CU was built with the flag and one built without it, it'd be possible/practical/easy to respect those differences, emitting linkage name for one CU and omitting it in another).

1470

I'd consider sinking the condition down into line 1476 so that we still check the metadata invariants around linkage names, if they're present, even if we're not emitting them.

test/DebugInfo/suppress-linkage-entry-3.ll
4 ↗(On Diff #14137)

I usually skip the temporary file and pipe the result of llc straight into llvm-dwarfdump (use '-' as the file name for llvm-dwarfdump to read standard input).

test/DebugInfo/suppress-linkage-entry-4.ll
8 ↗(On Diff #14137)

What's the important distinction between this test and the previous one? It looks like we've only got one codepath so I'm not sure if we need two test cases.

echristo added inline comments.
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
45

It's definitely a code gen option and so should go on a code gen option struct. That said, we're probably getting enough of them that a sub struct for debug info would be better.

i.e. I don't see why we'd want to handle adding or subtracting on a CU basis and thus need to put it on the metadata.

Thanks for the comments, David.

lib/CodeGen/AsmPrinter/DwarfUnit.cpp
45

Using a flag on the CU metadata is definitely preferable due to LTO. It also avoids cluttering up the command line, since we want to suppress the attributes unconditionally anyway (without breaking the existing debuginfo tests that check for them). I'll scratch the current change and start over.

test/DebugInfo/suppress-linkage-entry-4.ll
8 ↗(On Diff #14137)

Right, I was vainly trying to catch future dwarf-3/dwarf-4 deviations, but it doesn't seem worth it.

echristo added inline comments.Sep 26 2014, 4:10 PM
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
45

I'll be clear, it's not to go onto the CU metadata. There's no reason for it to do so.

wolfgangp updated this revision to Diff 14303.Oct 1 2014, 6:19 PM
wolfgangp retitled this revision from Option to suppress the DWARF entries DW_AT_MIPS_linkage_name and DW_AT_linkage_name. to Module flag to suppress the DWARF entries DW_AT_MIPS_linkage_name and DW_AT_linkage_name..
wolfgangp updated this object.

Based on everyone's feedback this is the second attempt at providing a way to suppress the DWARF linkage name attributes.

Instead of implementing a backend option, this change implements a metadata module flag “Dwarf Gen Flags”, which itself is intended as a list of flags controlling Dwarf emission. The only supported element of the list is “suppress-linkage-names” which, when present, causes the DWARF attributes DW_AT_MIPS_linkage_name and DW_AT_link_name to be suppressed.

This implementation works also for LTO, although the presence of the flag in one module suppresses the attributes for the entire link, which is different from the non-LTO behavior (only the attributes in the modules with the flag are suppressed).

wolfgangp updated this revision to Diff 15057.Oct 16 2014, 5:36 PM

Revised patch after recent changes to DwarfCompileUnit.

dblaikie added inline comments.Oct 17 2014, 11:21 AM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2326

So debug info already has 2 metadata flags (Dwarf Version and Debug Info Version (the version of the metadata schema)), this is a third, and they're all parsed in different places (interestingly the Dwarf Version is parsed in llvm::Module, but the Debug Info Version is parsed in a standalone function (in lib/DebugInfo) llvm::getDebugMetadataVersionFromModule) and this third will be a new place again.

Perhaps these should go somewhere common? Certainly the string constants should be written once (not repeated in every client of LLVM that wants to use them).

test/DebugInfo/suppress-linkage-entries.ll
52

I'm guessing this '6' is a merge specifier? What kind of merging does this designate?

wolfgangp added inline comments.Oct 17 2014, 12:09 PM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2326

It certainly seems that way. Being an llvm newbie I'm a bit hesitant to suggest more encompassing changes, but I'd be happy to give it a try.

test/DebugInfo/suppress-linkage-entries.ll
52

It's Module::ModFlagBehavior::AppendUnique, i.e. during a merge values from 2 lists will be appended but duplicates will be dropped.

wolfgangp abandoned this revision.Aug 14 2015, 2:16 PM

Abandoned. Functionality implemented with r244678.