Better pointer name equality optimization in DIE de-duplication code
authorDodji Seketeli <dodji@redhat.com>
Thu, 21 Mar 2019 17:32:38 +0000 (18:32 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 22 Mar 2019 13:43:04 +0000 (14:43 +0100)
commitea6ee4cac1bdaff58fd865527ba8c99d5ac3a60c
tree4aaf63b6844cbf11c65bcf502d4f439dfae7ccb5
parent782c3d8c429c383221e4cd5eb6cc9906c01aca11
Better pointer name equality optimization in DIE de-duplication code

During DIE de-duplication for the purpose of DIE canonicalization, we
use the so called "pointer name equality" optimization.  That is, when
in a given translation unit, we have two different pointers named T*,
we assume they are the same type, without having to compare their
pointed-to T types recursively.

Unfortunately, some Ts can be different, especially in C.  Think about
two typedefs with different underlying types, for instance.  Or two
struct with data members which types are pointers to typefefs with
different underlying types.  We are having the case in the libc binaries
provided in bug https://sourceware.org/bugzilla/show_bug.cgi?id=24257,
for instance.

In those case, we try not only to look at the name of the translation
unit associated to the pointer to T, but also, at the name of the
translation unit of the leaf node of T*.  By leaf node, I mean the
resulting of stripping T* from all pointers and typedefs.  This won't
solve the case of the Ts being structs with data members which types
are pointers to typedefs with different underlying types.  But it
helps with the easier earlier cases.

* src/abg-dwarf-reader.cc
(die_is_pointer_reference_or_typedef_type)
(die_peel_pointer_and_typedef): Define new static functions.
(compare_dies_string_attribute_value): Turn this function into a
static one.
(compare_dies_cu_decl_file): Make this function compare the cu
decl file name of the leaf type of the pointer, not just the one
of the pointer itself.
(compare_as_decl_dies): Compare the DWARF tags too.
(compare_dies): Simplify logic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc