diff mbox series

[3/8,applied] ir: Tighten type comparison optimization for Linux kernel binaries

Message ID 87y298c6ig.fsf@redhat.com
State New
Headers show
Series [1/8,applied] ir: Improve the debugging facilities | expand

Commit Message

Dodji Seketeli Aug. 11, 2021, 4:04 p.m. UTC

types_defined_same_linux_kernel_corpus_public() performs an
optimization while comparing two types in the context of the Linux
kernel.  If two types of the same kind and name are defined in the
same corpus and in the same file, then they ought to be equal.

For two anonymous classes that have naming typedefs, the function
forgets to ensure that the naming typedefs have the same name.

I have no binary that exhibits the potential issue, but I stumbled
upon the problem while looking at something else that uncovered
the problem.  This change doesn't impact any of the binaries of the
regression suite at the moment, though.

Fixed thus.

	* src/abg-ir.cc (types_defined_same_linux_kernel_corpus_public):
	Ensure that anonymous classes with naming typedefs have identical
	typedef names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
 src/abg-ir.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series


diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 8e00eabf..f7739186 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -13161,6 +13161,16 @@  types_defined_same_linux_kernel_corpus_public(const type_base& t1,
       || (c2 && c2->get_is_anonymous() && !c2->get_naming_typedef()))
     return false;
+  // Two anonymous classes with naming typedefs should have the same
+  // typedef name.
+  if (c1
+      && c2
+      && c1->get_is_anonymous() && c1->get_naming_typedef()
+      && c2->get_is_anonymous() && c2->get_naming_typedef())
+    if (c1->get_naming_typedef()->get_name()
+	!= c2->get_naming_typedef()->get_name())
+      return false;
   // Two anonymous enum types cannot be eligible to this optimization.
   if (const enum_type_decl *e1 = is_enum_type(&t1))
     if (const enum_type_decl *e2 = is_enum_type(&t2))