Implicit_const implementation related query.

Forwarding to Mailing list.
Hello Everyone,

I’m trying to implement DW_FORM_implicit_const as an experimental feature to evaluate its gain in the overall size reduction in debug info.

In my initial implementation, DW_FORM_implicit_const is emitted only when a constant attribute is same across multiple DIE’s.

This is accomplished, in process of uniquing of Abbrevs i.e if an Abbrev is duplicate that suggests it’s shared by multiple DIE’s, so we replaced the constant attributes[DW_AT_decl_file] {value, form} with DW_FORM_implicit_const in corresponding Abbrev.

The problem I’m facing, is in deletion of the attribute[DW_AT_decl_file] from DIE’s[debug_info] that are using this abbrev. These DIE’s are laid out as DIEValueList, Is there a way to cleanly remove a node[Attribute] from this list ??

Can anybody share comments/thoughts on the implementation side of this and suggest how to overcome the deletion of attributes from the DIEs in the debug_info section.

Thank You,
Sourabh.

Dynamically choosing form based on usage isn’t something that’s been done in LLVM’s DWARF emission thus far and would probably be a significant amount of work to implement. (I don’t really recommend it)

But the way the existing similar support for DW_FORM_flag_present works is that it’s explicitly chosen when creating the attributes/DIEs - it might be that by collecting some data you could show that most values for certain attributes on certain DIEs share the same value and then explicitly construct those using implicit_const always, rather than conditionally. (eg: maybe the private/public part of member descriptions could always be emitted with implicit_const)

This sort of hardcoded heuristic approach of course will not always yield optimal results but might have some gains.