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>