From 8d11a8dd9ec92399d1d0c54ea8a1f311e4917fb1 Mon Sep 17 00:00:00 2001 From: Krzysztof Drewniak Date: Mon, 28 Apr 2025 23:39:53 +0000 Subject: [PATCH] [NFC][AMDGPU] Drop recursive types in LowerBufferFatPointers Now that IRMover and the rest of LLVM don't allow recursive types, drop support for them from the clone of the IRMover code used when lowering buffer fat pointer operations. --- .../AMDGPU/AMDGPULowerBufferFatPointers.cpp | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp index 7163ad2aa7dca..284f6ede2b85b 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp @@ -267,7 +267,7 @@ namespace { class BufferFatPtrTypeLoweringBase : public ValueMapTypeRemapper { DenseMap Map; - Type *remapTypeImpl(Type *Ty, SmallPtrSetImpl &Seen); + Type *remapTypeImpl(Type *Ty); protected: virtual Type *remapScalar(PointerType *PT) = 0; @@ -305,8 +305,7 @@ class BufferFatPtrToStructTypeMap : public BufferFatPtrTypeLoweringBase { } // namespace // This code is adapted from the type remapper in lib/Linker/IRMover.cpp -Type *BufferFatPtrTypeLoweringBase::remapTypeImpl( - Type *Ty, SmallPtrSetImpl &Seen) { +Type *BufferFatPtrTypeLoweringBase::remapTypeImpl(Type *Ty) { Type **Entry = &Map[Ty]; if (*Entry) return *Entry; @@ -331,18 +330,11 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl( // require recursion. if (Ty->getNumContainedTypes() == 0 && IsUniqued) return *Entry = Ty; - if (!IsUniqued) { - // Create a dummy type for recursion purposes. - if (!Seen.insert(TyAsStruct).second) { - StructType *Placeholder = StructType::create(Ty->getContext()); - return *Entry = Placeholder; - } - } bool Changed = false; SmallVector ElementTypes(Ty->getNumContainedTypes(), nullptr); for (unsigned int I = 0, E = Ty->getNumContainedTypes(); I < E; ++I) { Type *OldElem = Ty->getContainedType(I); - Type *NewElem = remapTypeImpl(OldElem, Seen); + Type *NewElem = remapTypeImpl(OldElem); ElementTypes[I] = NewElem; Changed |= (OldElem != NewElem); } @@ -366,13 +358,6 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl( return *Entry = StructType::get(Ty->getContext(), ElementTypes, IsPacked); SmallString<16> Name(STy->getName()); STy->setName(""); - Type **RecursionEntry = &Map[Ty]; - if (*RecursionEntry) { - auto *Placeholder = cast(*RecursionEntry); - Placeholder->setBody(ElementTypes, IsPacked); - Placeholder->setName(Name); - return *Entry = Placeholder; - } return *Entry = StructType::create(Ty->getContext(), ElementTypes, Name, IsPacked); } @@ -380,8 +365,7 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl( } Type *BufferFatPtrTypeLoweringBase::remapType(Type *SrcTy) { - SmallPtrSet Visited; - return remapTypeImpl(SrcTy, Visited); + return remapTypeImpl(SrcTy); } Type *BufferFatPtrToStructTypeMap::remapScalar(PointerType *PT) {