[llvm] 94dc0a0 - [NFC][AMDGPU] Drop recursive types in LowerBufferFatPointers (#137735)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 07:23:43 PDT 2025
Author: Krzysztof Drewniak
Date: 2025-04-29T07:23:40-07:00
New Revision: 94dc0a0e7bc723af13a0923aa102fcc4d03c82a2
URL: https://github.com/llvm/llvm-project/commit/94dc0a0e7bc723af13a0923aa102fcc4d03c82a2
DIFF: https://github.com/llvm/llvm-project/commit/94dc0a0e7bc723af13a0923aa102fcc4d03c82a2.diff
LOG: [NFC][AMDGPU] Drop recursive types in LowerBufferFatPointers (#137735)
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.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
Removed:
################################################################################
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<Type *, Type *> Map;
- Type *remapTypeImpl(Type *Ty, SmallPtrSetImpl<StructType *> &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<StructType *> &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<Type *> 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<StructType>(*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<StructType *, 2> Visited;
- return remapTypeImpl(SrcTy, Visited);
+ return remapTypeImpl(SrcTy);
}
Type *BufferFatPtrToStructTypeMap::remapScalar(PointerType *PT) {
More information about the llvm-commits
mailing list