[llvm] [IRMover] Don't consider opaque types isomorphic to other types (PR #138241)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 30 07:58:48 PDT 2025
================
@@ -93,35 +74,8 @@ class TypeMapTy : public ValueMapTypeRemapper {
}
void TypeMapTy::addTypeMapping(Type *DstTy, Type *SrcTy) {
- assert(SpeculativeTypes.empty());
- assert(SpeculativeDstOpaqueTypes.empty());
-
- // Check to see if these types are recursively isomorphic and establish a
- // mapping between them if so.
- if (!areTypesIsomorphic(DstTy, SrcTy)) {
- // Oops, they aren't isomorphic. Just discard this request by rolling out
- // any speculative mappings we've established.
- for (Type *Ty : SpeculativeTypes)
- MappedTypes.erase(Ty);
-
- SrcDefinitionsToResolve.resize(SrcDefinitionsToResolve.size() -
- SpeculativeDstOpaqueTypes.size());
- for (StructType *Ty : SpeculativeDstOpaqueTypes)
- DstResolvedOpaqueTypes.erase(Ty);
- } else {
- // SrcTy and DstTy are recursively ismorphic. We clear names of SrcTy
- // and all its descendants to lower amount of renaming in LLVM context
- // Renaming occurs because we load all source modules to the same context
- // and declaration with existing name gets renamed (i.e Foo -> Foo.42).
- // As a result we may get several different types in the destination
- // module, which are in fact the same.
- for (Type *Ty : SpeculativeTypes)
- if (auto *STy = dyn_cast<StructType>(Ty))
- if (STy->hasName())
- STy->setName("");
- }
- SpeculativeTypes.clear();
- SpeculativeDstOpaqueTypes.clear();
+ // areTypesIsomorphic() will also establish the type mapping as a side effect.
----------------
teresajohnson wrote:
Suggest renaming this method to reflect that it is doing more than checking (realize this is not a result of your changes here but it would be clearer).
https://github.com/llvm/llvm-project/pull/138241
More information about the llvm-commits
mailing list