Introduce on-the-fly type canonicalization
During canonicalization of a type T, when T is structurally compared
to an already canonicalized type C, it can happen that
non-canonicalized sub-types of T are structurally compared again and
again to canonicalized sub-types of C.
This patch introduces a new optimization or those cases: on-the-fly
type canonicalized.
That means, if a not-yet-canonicalized sub-type S of the type T being
canonicalized structurally compares equal to a canonicalized sub-type,
then the canonical type of S is said to be the canonical type of the
canonicalized sub-type. So sub-type S is canonicalized, on-the-fly,
during canonicalization of type T.
This considerably speeds up the canonicalization process while doing
"abidiff vmlinux vmlinux". It goes from taking forever to taking 45
seconds on a non-optimized build.
* include/abg-ir.h (environment::do_on_the_fly_canonicalization):
Declare new member functions.
({type_base, function_type}::priv_): Make this public so that
static non-member functions defined in abg-ir.cc can access it.
* src/abg-ir.cc
(environment::priv::do_on_the_fly_canonicalization_): New data
member.
(environment::priv::priv): Initialize it.
(environment::do_on_the_fly_canonicalization): Define new member
functions.
(type_base::get_canonical_type_for): Trigger on-the-fly
canonicalization during comparison of the type being canonicalized
and an already canonicalized type.
(types_are_being_compared, maybe_propagate_canonical_type): Define
new static functions.
(equals): In overloads for class_decl and function_type, call
maybe_propagate_canonical_type when the two types compare equal.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>