@@ -267,7 +267,7 @@ namespace {
267267class BufferFatPtrTypeLoweringBase : public ValueMapTypeRemapper {
268268 DenseMap<Type *, Type *> Map;
269269
270- Type *remapTypeImpl (Type *Ty, SmallPtrSetImpl<StructType *> &Seen );
270+ Type *remapTypeImpl (Type *Ty);
271271
272272protected:
273273 virtual Type *remapScalar (PointerType *PT) = 0;
@@ -305,8 +305,7 @@ class BufferFatPtrToStructTypeMap : public BufferFatPtrTypeLoweringBase {
305305} // namespace
306306
307307// This code is adapted from the type remapper in lib/Linker/IRMover.cpp
308- Type *BufferFatPtrTypeLoweringBase::remapTypeImpl (
309- Type *Ty, SmallPtrSetImpl<StructType *> &Seen) {
308+ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl (Type *Ty) {
310309 Type **Entry = &Map[Ty];
311310 if (*Entry)
312311 return *Entry;
@@ -331,18 +330,11 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl(
331330 // require recursion.
332331 if (Ty->getNumContainedTypes () == 0 && IsUniqued)
333332 return *Entry = Ty;
334- if (!IsUniqued) {
335- // Create a dummy type for recursion purposes.
336- if (!Seen.insert (TyAsStruct).second ) {
337- StructType *Placeholder = StructType::create (Ty->getContext ());
338- return *Entry = Placeholder;
339- }
340- }
341333 bool Changed = false ;
342334 SmallVector<Type *> ElementTypes (Ty->getNumContainedTypes (), nullptr );
343335 for (unsigned int I = 0 , E = Ty->getNumContainedTypes (); I < E; ++I) {
344336 Type *OldElem = Ty->getContainedType (I);
345- Type *NewElem = remapTypeImpl (OldElem, Seen );
337+ Type *NewElem = remapTypeImpl (OldElem);
346338 ElementTypes[I] = NewElem;
347339 Changed |= (OldElem != NewElem);
348340 }
@@ -366,22 +358,14 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl(
366358 return *Entry = StructType::get (Ty->getContext (), ElementTypes, IsPacked);
367359 SmallString<16 > Name (STy->getName ());
368360 STy->setName (" " );
369- Type **RecursionEntry = &Map[Ty];
370- if (*RecursionEntry) {
371- auto *Placeholder = cast<StructType>(*RecursionEntry);
372- Placeholder->setBody (ElementTypes, IsPacked);
373- Placeholder->setName (Name);
374- return *Entry = Placeholder;
375- }
376361 return *Entry = StructType::create (Ty->getContext (), ElementTypes, Name,
377362 IsPacked);
378363 }
379364 llvm_unreachable (" Unknown type of type that contains elements" );
380365}
381366
382367Type *BufferFatPtrTypeLoweringBase::remapType (Type *SrcTy) {
383- SmallPtrSet<StructType *, 2 > Visited;
384- return remapTypeImpl (SrcTy, Visited);
368+ return remapTypeImpl (SrcTy);
385369}
386370
387371Type *BufferFatPtrToStructTypeMap::remapScalar (PointerType *PT) {
0 commit comments