Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -366,22 +358,14 @@ 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);
}
llvm_unreachable("Unknown type of type that contains elements");
}

Type *BufferFatPtrTypeLoweringBase::remapType(Type *SrcTy) {
SmallPtrSet<StructType *, 2> Visited;
return remapTypeImpl(SrcTy, Visited);
return remapTypeImpl(SrcTy);
}

Type *BufferFatPtrToStructTypeMap::remapScalar(PointerType *PT) {
Expand Down
Loading