On Aug 30, 2016, Alexandre Oliva <aol...@redhat.com> wrote: > Handling non-template friends is kind of easy, but it required a bit > of infrastructure in dwarf2out to avoid (i) forcing debug info for > unused types or functions: DW_TAG_friend DIEs are only emitted if > their DW_AT_friend DIE is emitted, and (ii) creating DIEs for such > types or functions just to have them discarded at the end. To this > end, I introduced a list (vec, actually) of types with friends, > processed at the end of the translation unit, and a list of > DW_TAG_friend DIEs that, when we're pruning unused types, reference > DIEs that are still not known to be used, revisited after we finish > deciding all other DIEs, so that we prune DIEs that would have > referenced pruned types or functions.
> Handling template friends turned out to be trickier: there's no > representation in DWARF for templates. I decided to give debuggers as > much information as possible, enumerating all specializations of > friend templates and outputting DW_TAG_friend DIEs referencing them as > well. I considered marking those as DW_AT_artificial, to indicate > they're not explicitly stated in the source code, but in the end we > decided that was not useful. The greatest challenge was to enumerate > all specializations of a template. It looked trivial at first, given > DECL_TEMPLATE_INSTANTIATIONS, but it won't list specializations of > class-scoped functions and of nested templates. For other templates, > I ended up writing code to look for specializations in the hashtables > of decl or type specializations. That's not exactly efficient, but it > gets the job done. Regstrapped on x86_64-linux-gnu and i686-linux-gnu, I'd failed to mention. Ping? https://gcc.gnu.org/ml/gcc-patches/2016-08/msg02092.html -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer