public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: dwz@sourceware.org
Subject: [Bug default/25567] New: [dwz] Factor out common parts in different namespaces
Date: Wed, 01 Jan 2020 00:00:00 -0000	[thread overview]
Message-ID: <bug-25567-11298@http.sourceware.org/bugzilla/> (raw)

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.

                 reply	other threads:[~2020-02-17 16:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-25567-11298@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=dwz@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).