summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2016-11-08 12:22:50 +0100
committerDodji Seketeli <dodji@redhat.com>2016-11-10 14:09:50 +0100
commitce6513ee72ae4c0b4dadabe59d818020faaed10a (patch)
tree8d84bb27be5a05aaaea2a28b4c0c1733dc262ec5
parentMisc style cleanups in abg-ir.cc (diff)
downloadlibabigail-ce6513ee72ae4c0b4dadabe59d818020faaed10a.tar.gz
libabigail-ce6513ee72ae4c0b4dadabe59d818020faaed10a.tar.bz2
libabigail-ce6513ee72ae4c0b4dadabe59d818020faaed10a.tar.xz
Avoid stripping typedefs too much
strip_typedef re-constructs entire type trees and canonicalize them. Calling it a lot on very deep and recursive trees can be costly. Unfortunately, categorization of changes uses strip_typedef quite a bit to determine if the two types that are different are still compatible. When used on changesets generating from comparing two Linux Kernels, it makes changes categorization dominate CPU usage profiles. This patch avoids using strip_typedef to determine if two types are compatible and thus speeds up type categorization of changes involving lots of deep and recursive type trees. * src/abg-ir.cc (types_are_compatible) (is_compatible_with_class_type): Do not strip typedefs. Just get their leaf types. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--src/abg-ir.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 8b6c4cea..e52d2736 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -5470,8 +5470,21 @@ types_are_compatible(const type_base_sptr type1,
5470 if (!type1 || !type2) 5470 if (!type1 || !type2)
5471 return false; 5471 return false;
5472 5472
5473 type_base_sptr t1 = strip_typedef(type1); 5473 if (type1 == type2)
5474 type_base_sptr t2 = strip_typedef(type2); 5474 return true;
5475
5476 // Normally we should strip typedefs entirely, but this is
5477 // potentially costly, especially on binaries with huge changesets
5478 // like the Linux Kernel. So we just get the leaf types for now.
5479 //
5480 // Maybe there should be an option by which users accepts to pay the
5481 // CPU usage toll in exchange for finer filtering?
5482
5483 // type_base_sptr t1 = strip_typedef(type1);
5484 // type_base_sptr t2 = strip_typedef(type2);
5485
5486 type_base_sptr t1 = peel_typedef_type(type1);
5487 type_base_sptr t2 = peel_typedef_type(type2);
5475 5488
5476 return t1 == t2; 5489 return t1 == t2;
5477} 5490}
@@ -5866,7 +5879,16 @@ is_compatible_with_class_type(const type_base_sptr& t)
5866{ 5879{
5867 if (!t) 5880 if (!t)
5868 return class_decl_sptr(); 5881 return class_decl_sptr();
5869 type_base_sptr ty = strip_typedef(t); 5882
5883 // Normally we should strip typedefs entirely, but this is
5884 // potentially costly, especially on binaries with huge changesets
5885 // like the Linux Kernel. So we just get the leaf types for now.
5886 //
5887 // Maybe there should be an option by which users accepts to pay the
5888 // CPU usage toll in exchange for finer filtering?
5889
5890 // type_base_sptr ty = strip_typedef(t);
5891 type_base_sptr ty = peel_typedef_type(t);;
5870 return is_class_type(ty); 5892 return is_class_type(ty);
5871} 5893}
5872 5894