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/27438] New: [dwz, odr, multifile] Multifile after odr not optimal
Date: Fri, 19 Feb 2021 08:45:13 +0000	[thread overview]
Message-ID: <bug-27438-11298@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 27438
           Summary: [dwz, odr, multifile] Multifile after odr not optimal
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: normal
          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 odr-struct:
...
$ make odr-struct
...

It has two structs aaa (from different CUs), each with member of type bbb and
ccc, but in one case bbb is a decl, in the other case ccc is a decl:
...
$ readelf -wi odr-struct | egrep -A2 "DW_TAG_structure" | egrep
"DW_TAG|DW_AT_name|DW_AT_decl"
 <1><f4>: Abbrev Number: 2 (DW_TAG_structure_type)
    <f5>   DW_AT_name        : ccc
 <1><114>: Abbrev Number: 2 (DW_TAG_structure_type)
    <115>   DW_AT_name        : aaa
 <1><139>: Abbrev Number: 5 (DW_TAG_structure_type)
    <13a>   DW_AT_name        : bbb
    <13e>   DW_AT_declaration : 1
 <1><1af>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1b0>   DW_AT_name        : bbb
 <1><1cf>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1d0>   DW_AT_name        : aaa
 <1><1fa>: Abbrev Number: 6 (DW_TAG_structure_type)
    <1fb>   DW_AT_name        : ccc
    <1ff>   DW_AT_declaration : 1
...

And we keep the same when doing dwz:
...
$ cp odr-struct 1; ./dwz 1
$ readelf -wi 1 | egrep -A2 "DW_TAG_structure" | egrep
"DW_TAG|DW_AT_name|DW_AT_decl" <1><e7>: Abbrev Number: 23
(DW_TAG_structure_type)
    <e8>   DW_AT_name        : ccc
 <1><101>: Abbrev Number: 23 (DW_TAG_structure_type)
    <102>   DW_AT_name        : aaa
 <1><11d>: Abbrev Number: 27 (DW_TAG_structure_type)
    <11e>   DW_AT_name        : bbb
    <122>   DW_AT_declaration : 1
 <1><17d>: Abbrev Number: 23 (DW_TAG_structure_type)
    <17e>   DW_AT_name        : bbb
 <1><197>: Abbrev Number: 23 (DW_TAG_structure_type)
    <198>   DW_AT_name        : aaa
 <1><1b6>: Abbrev Number: 27 (DW_TAG_structure_type)
    <1b7>   DW_AT_name        : ccc
    <1bb>   DW_AT_declaration : 1
...

When doing odr, we end up with one struct aaa, and no decls:
...
$ cp odr-struct 1; ./dwz 1 --odr
$ readelf -wi 1 | egrep -A2 "DW_TAG_structure" | egrep
"DW_TAG|DW_AT_name|DW_AT_decl"
 <1><19>: Abbrev Number: 25 (DW_TAG_structure_type)
    <1a>   DW_AT_name        : ccc
 <1><2f>: Abbrev Number: 25 (DW_TAG_structure_type)
    <30>   DW_AT_name        : aaa
 <1><4b>: Abbrev Number: 25 (DW_TAG_structure_type)
    <4c>   DW_AT_name        : bbb
...

Now consider:
...
$ cp odr-struct 1; cp 1 2; ./dwz -m 3 1 2 --odr 
...
The desired outcome is that the structs aaa are unified in both 1 and 2, and
then moved to multifile 3.

Sofar, so good:
...
$ readelf -wi 3 | egrep -A2 "DW_TAG_structure" | egrep
"DW_TAG|DW_AT_name|DW_AT_decl"
 <1><14>: Abbrev Number: 15 (DW_TAG_structure_type)
    <15>   DW_AT_name        : ccc
 <1><2a>: Abbrev Number: 15 (DW_TAG_structure_type)
    <2b>   DW_AT_name        : aaa
 <1><46>: Abbrev Number: 15 (DW_TAG_structure_type)
    <47>   DW_AT_name        : bbb
...

But:
...
$ readelf -wi 1 | egrep -A2 "DW_TAG_structure" | egrep
"DW_TAG|DW_AT_name|DW_AT_decl"
 <1><1e>: Abbrev Number: 12 (DW_TAG_structure_type)
    <1f>   DW_AT_name        : aaa
 <1><3d>: Abbrev Number: 12 (DW_TAG_structure_type)
    <3e>   DW_AT_name        : bbb
...

And it's not just that these are dead dies left behind.  The 0x1e DIE is used
here:
...
 <1><114>: Abbrev Number: 20 (DW_TAG_variable)
    <115>   DW_AT_name        : (alt indirect string, offset: 0xe)
    <11b>   DW_AT_type        : <0x1e>
...

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

             reply	other threads:[~2021-02-19  8:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-19  8:45 vries at gcc dot gnu.org [this message]
2021-02-19 11:50 ` [Bug default/27438] " vries at gcc dot gnu.org
2021-02-19 12:08 ` vries at gcc dot gnu.org
2021-02-19 12:10 ` vries at gcc dot gnu.org
2021-02-19 12:24 ` vries at gcc dot gnu.org
2021-02-22  8:25 ` vries at gcc dot gnu.org
2021-02-22 15:12 ` vries at gcc dot gnu.org
2021-02-25 14:53 ` vries at gcc dot gnu.org

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-27438-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).