Bug 26679 - Perform dead DIE removal in dwz
Summary: Perform dead DIE removal in dwz
Status: NEW
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Nobody
Depends on:
Reported: 2020-09-30 07:35 UTC by Jakub Jelinek
Modified: 2021-03-02 07:52 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2020-09-30 07:35:44 UTC
E.g. on:
struct S { virtual ~S () {} int s; };
S s;
int main () {}
struct S { virtual ~S () {} int s; };
S t;
without -flto both the S::~S() dtors will be emitted with DW_AT_low_pc etc. and all the details, but as the definition is comdat, only one of them will be chosen by the linker and therefore the other one will end up with DW_AT_low_pc of 0.
It would be nice if dwz could perform some form of dead DIE removal, it should be very easy to discover them (subroutine or variable DIEs with zero addresses), but the question is what to do with those exactly.  Just drop those DIEs and their children, or e.g. first check if there is a real definition DIE for that entity elsewhere and drop only then?  Or just prune some sub-DIEs and some attributes?
Dropping DIEs or parts of DIEs shouldn't be that hard, but I guess dropping stuff from .debug_loc/.debug_loclists if they are never referenced because of such removal would be harder, there is no code for that right now.
On the bright side, this is something that would need to be done only at the single executable/DSO mode, at multifile processing which is more memory intensive this would be already done.
And, haven't checked, but probably it isn't relevant to -flto, because then the compiler emits or should emit only one definition.