public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/25567] New: [dwz] Factor out common parts in different namespaces
@ 2020-01-01  0:00 vries at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: vries at gcc dot gnu.org @ 2020-01-01  0:00 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=25567

            Bug ID: 25567
           Summary: [dwz] Factor out common parts in different namespaces
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: default
          Assignee: nobody at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: dwz at sourceware dot org
  Target Milestone: ---

Consider test.c:
...
namespace ns_a {
  class c {
    int i;
  };
};

namespace ns_b {
  class c {
    int i;
  };
};

ns_a::c c1;
ns_b::c c2;

int
main (void)
{
  return 0;
}
...

Compiled like this:
...
$ g++ test.c -g
...

we end up with ns_a:
...
 <1><f4>: Abbrev Number: 2 (DW_TAG_namespace)
    <f5>   DW_AT_name        : (indirect string, offset: 0x205): ns_a
    <f9>   DW_AT_decl_file   : 1
    <fa>   DW_AT_decl_line   : 1
    <fb>   DW_AT_sibling     : <0x111>
 <2><ff>: Abbrev Number: 3 (DW_TAG_class_type)
    <100>   DW_AT_name        : c
    <102>   DW_AT_byte_size   : 4
    <103>   DW_AT_decl_file   : 1
    <104>   DW_AT_decl_line   : 2
 <3><105>: Abbrev Number: 4 (DW_TAG_member)
    <106>   DW_AT_name        : i
    <108>   DW_AT_decl_file   : 1
    <109>   DW_AT_decl_line   : 3
    <10a>   DW_AT_type        : <0x111>
    <10e>   DW_AT_data_member_location: 0
...
and ns_b:
...
 <1><118>: Abbrev Number: 2 (DW_TAG_namespace)
    <119>   DW_AT_name        : (indirect string, offset: 0x20a): ns_b
    <11d>   DW_AT_decl_file   : 1
    <11e>   DW_AT_decl_line   : 7
    <11f>   DW_AT_sibling     : <0x135>
 <2><123>: Abbrev Number: 3 (DW_TAG_class_type)
    <124>   DW_AT_name        : c
    <126>   DW_AT_byte_size   : 4
    <127>   DW_AT_decl_file   : 1
    <128>   DW_AT_decl_line   : 8
 <3><129>: Abbrev Number: 4 (DW_TAG_member)
    <12a>   DW_AT_name        : i
    <12c>   DW_AT_decl_file   : 1
    <12d>   DW_AT_decl_line   : 9
    <12e>   DW_AT_type        : <0x111>
    <132>   DW_AT_data_member_location: 0
...

The class c DIEs of the two namespaces are identical (ignoring location info),
but even if we try to force compression:
...
$ dwz a.out -o 1 --devel-ignore-size --devel-ignore-loc
...
the DIEs in the namespaces stay the same.

How so?

Dwz currently handles namespaces conservatively: two DIEs in different
namespaces will always be considered unequal.

And if two DIEs are found to be equal, as well as in identical namespaces, then
the DIE is instantiated in the partial unit embedded in the namespace and
imported at top-level.  [ As opposed to moving the non-toplevel DIE to the
partial unit at top-level, and importing the partial unit into the namespaces
at the non-toplevel use sites.  Obviously doing things like this means the
partial unit is a non-toplevel one, and we can't move top-level DIEs there, so
this potentially makes things less efficient. ]

According to appendix E.1, it's possible to factor out the class c DIEs into a
partial unit, and import that partial unit into each namespace.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-17 16:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [Bug default/25567] New: [dwz] Factor out common parts in different namespaces vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).