[llvm] [IRMover] Remove Visited set in type mapping (NFC) (PR #137329)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 06:33:33 PDT 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/137329
LLVM no longer supports recursive types, so the Visited set is unnecessary.
>From 64f27eea22326aef519232566102c4286175cc71 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 25 Apr 2025 15:32:33 +0200
Subject: [PATCH] [IRMover] Remove Visited set in type mapping (NFC)
LLVM no longer supports recursive types, so the Visited set is
unnecessary.
---
llvm/lib/Linker/IRMover.cpp | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 26a9a161a8fd7..98d69051c935a 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -80,7 +80,6 @@ class TypeMapTy : public ValueMapTypeRemapper {
/// Return the mapped type to use for the specified input type from the
/// source module.
Type *get(Type *SrcTy);
- Type *get(Type *SrcTy, SmallPtrSet<StructType *, 8> &Visited);
FunctionType *get(FunctionType *T) {
return cast<FunctionType>(get((Type *)T));
@@ -232,11 +231,6 @@ Error TypeMapTy::linkDefinedTypeBodies() {
}
Type *TypeMapTy::get(Type *Ty) {
- SmallPtrSet<StructType *, 8> Visited;
- return get(Ty, Visited);
-}
-
-Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
// If we already have an entry for this type, return it.
Type **Entry = &MappedTypes[Ty];
if (*Entry)
@@ -252,11 +246,6 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
"mapping to a source type");
}
#endif
-
- if (!Visited.insert(cast<StructType>(Ty)).second) {
- StructType *DTy = StructType::create(Ty->getContext());
- return *Entry = DTy;
- }
}
// If this is not a recursive type, then just map all of the elements and
@@ -272,7 +261,7 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
bool AnyChange = false;
ElementTypes.resize(Ty->getNumContainedTypes());
for (unsigned I = 0, E = Ty->getNumContainedTypes(); I != E; ++I) {
- ElementTypes[I] = get(Ty->getContainedType(I), Visited);
+ ElementTypes[I] = get(Ty->getContainedType(I));
AnyChange |= ElementTypes[I] != Ty->getContainedType(I);
}
More information about the llvm-commits
mailing list