@@ -267,7 +267,7 @@ namespace {
267
267
class BufferFatPtrTypeLoweringBase : public ValueMapTypeRemapper {
268
268
DenseMap<Type *, Type *> Map;
269
269
270
- Type *remapTypeImpl (Type *Ty, SmallPtrSetImpl<StructType *> &Seen );
270
+ Type *remapTypeImpl (Type *Ty);
271
271
272
272
protected:
273
273
virtual Type *remapScalar (PointerType *PT) = 0;
@@ -305,8 +305,7 @@ class BufferFatPtrToStructTypeMap : public BufferFatPtrTypeLoweringBase {
305
305
} // namespace
306
306
307
307
// 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) {
310
309
Type **Entry = &Map[Ty];
311
310
if (*Entry)
312
311
return *Entry;
@@ -331,18 +330,11 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl(
331
330
// require recursion.
332
331
if (Ty->getNumContainedTypes () == 0 && IsUniqued)
333
332
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
- }
341
333
bool Changed = false ;
342
334
SmallVector<Type *> ElementTypes (Ty->getNumContainedTypes (), nullptr );
343
335
for (unsigned int I = 0 , E = Ty->getNumContainedTypes (); I < E; ++I) {
344
336
Type *OldElem = Ty->getContainedType (I);
345
- Type *NewElem = remapTypeImpl (OldElem, Seen );
337
+ Type *NewElem = remapTypeImpl (OldElem);
346
338
ElementTypes[I] = NewElem;
347
339
Changed |= (OldElem != NewElem);
348
340
}
@@ -366,22 +358,14 @@ Type *BufferFatPtrTypeLoweringBase::remapTypeImpl(
366
358
return *Entry = StructType::get (Ty->getContext (), ElementTypes, IsPacked);
367
359
SmallString<16 > Name (STy->getName ());
368
360
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
- }
376
361
return *Entry = StructType::create (Ty->getContext (), ElementTypes, Name,
377
362
IsPacked);
378
363
}
379
364
llvm_unreachable (" Unknown type of type that contains elements" );
380
365
}
381
366
382
367
Type *BufferFatPtrTypeLoweringBase::remapType (Type *SrcTy) {
383
- SmallPtrSet<StructType *, 2 > Visited;
384
- return remapTypeImpl (SrcTy, Visited);
368
+ return remapTypeImpl (SrcTy);
385
369
}
386
370
387
371
Type *BufferFatPtrToStructTypeMap::remapScalar (PointerType *PT) {
0 commit comments