comp-filter: Speed up harmless/harmful categorization
authorDodji Seketeli <dodji@redhat.com>
Thu, 16 Feb 2023 17:06:44 +0000 (18:06 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 2 Mar 2023 17:31:43 +0000 (18:31 +0100)
Categorizing a diff graph with a thousands of function diff nodes takes a
lot of time.  At that point, categorizing each node has
harmful/harmless is showing up in the profile, particularly because
has_var_type_cv_qual_change and to a lesser extend
class_diff_has_harmless_odr_violation_change perform some structural
comparison still, oops.  This patch avoids doing that.  On my machine,
the categorizing of each node goes from around 130ms to 92 ms.

* src/abg-comp-filter.cc
(class_diff_has_harmless_odr_violation_change)
(has_var_type_cv_qual_change): Avoid doing structural comparison
here.

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

index 5300d07c5938bb9c47d83a8c68bb65a5c8df6962..f1d67de5002a70b4901317deb4b74fa9513f07de 100644 (file)
@@ -775,14 +775,10 @@ class_diff_has_harmless_odr_violation_change(const diff* dif)
   class_decl_sptr first = d->first_class_decl();
   class_decl_sptr second = d->second_class_decl();
 
-  if (equals(*first, *second, 0))
-    {
-      class_decl_sptr fc = is_class_type(first->get_canonical_type());
-      class_decl_sptr sc = is_class_type(second->get_canonical_type());
-
-      if (!equals(*fc, *sc, 0))
-       return true;
-    }
+  if (first->get_qualified_name() == second->get_qualified_name()
+      && first != second
+      && first->get_corpus() == second->get_corpus())
+    return true;
 
   return false;
 }
@@ -1643,18 +1639,9 @@ has_var_type_cv_qual_change(const diff* dif)
   if (!var_dif)
     return false;
 
-  {
-    // Make sure the variable diff does carry a type change at least
-    change_kind ch_kind = NO_CHANGE_KIND;
-    if (equals(*var_dif->first_var(), *var_dif->second_var(), &ch_kind))
-      return false;
-
-    if (!(ch_kind & LOCAL_TYPE_CHANGE_KIND || ch_kind & SUBTYPE_CHANGE_KIND))
-      return false;
-  }
-
   diff *type_dif = var_dif->type_diff().get();
-  ABG_ASSERT(type_dif);
+  if (!type_dif)
+    return false;
 
   return type_diff_has_cv_qual_change_only(type_dif);
 }