[llvm] [IRMover] Don't consider opaque types isomorphic to other types (PR #138241)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 08:38:52 PDT 2025


================
@@ -196,38 +131,27 @@ bool TypeMapTy::areTypesIsomorphic(Type *DstTy, Type *SrcTy) {
       return false;
   }
 
-  // Otherwise, we speculate that these two types will line up and recursively
-  // check the subelements.
-  Entry = DstTy;
-  SpeculativeTypes.push_back(SrcTy);
-
+  // Recursively check the subelements.
   for (unsigned I = 0, E = SrcTy->getNumContainedTypes(); I != E; ++I)
     if (!areTypesIsomorphic(DstTy->getContainedType(I),
                             SrcTy->getContainedType(I)))
       return false;
 
   // If everything seems to have lined up, then everything is great.
-  return true;
-}
+  [[maybe_unused]] auto Res = MappedTypes.insert({SrcTy, DstTy});
----------------
nikic wrote:

It's a bit hidden. We take a reference into MappedTypes here: https://github.com/llvm/llvm-project/blob/f8d3bdf6a2720b68a32c4588d5a2a8840fc882d3/llvm/lib/Linker/IRMover.cpp#L135 and then this stores into it: https://github.com/llvm/llvm-project/blob/f8d3bdf6a2720b68a32c4588d5a2a8840fc882d3/llvm/lib/Linker/IRMover.cpp#L201

I've replaced it with the insert() because it now happens after the recursive calls, so it's possible to the reference has been invalidated in the meantime.

https://github.com/llvm/llvm-project/pull/138241


More information about the llvm-commits mailing list