@@ -82,8 +82,6 @@ class TypeMapTy : public ValueMapTypeRemapper {
8282 Type *get (Type *SrcTy);
8383 Type *get (Type *SrcTy, SmallPtrSet<StructType *, 8 > &Visited);
8484
85- void finishType (StructType *DTy, StructType *STy, ArrayRef<Type *> ETypes);
86-
8785 FunctionType *get (FunctionType *T) {
8886 return cast<FunctionType>(get ((Type *)T));
8987 }
@@ -233,20 +231,6 @@ Error TypeMapTy::linkDefinedTypeBodies() {
233231 return Error::success ();
234232}
235233
236- void TypeMapTy::finishType (StructType *DTy, StructType *STy,
237- ArrayRef<Type *> ETypes) {
238- DTy->setBody (ETypes, STy->isPacked ());
239-
240- // Steal STy's name.
241- if (STy->hasName ()) {
242- SmallString<16 > TmpName = STy->getName ();
243- STy->setName (" " );
244- DTy->setName (TmpName);
245- }
246-
247- DstStructTypesSet.addNonOpaque (DTy);
248- }
249-
250234Type *TypeMapTy::get (Type *Ty) {
251235 SmallPtrSet<StructType *, 8 > Visited;
252236 return get (Ty, Visited);
@@ -292,17 +276,9 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
292276 AnyChange |= ElementTypes[I] != Ty->getContainedType (I);
293277 }
294278
295- // If we found our type while recursively processing stuff, just use it .
279+ // Refresh Entry after recursively processing stuff.
296280 Entry = &MappedTypes[Ty];
297- if (*Entry) {
298- if (auto *DTy = dyn_cast<StructType>(*Entry)) {
299- if (DTy->isOpaque ()) {
300- auto *STy = cast<StructType>(Ty);
301- finishType (DTy, STy, ElementTypes);
302- }
303- }
304- return *Entry;
305- }
281+ assert (!*Entry && " Recursive type!" );
306282
307283 // If all of the element types mapped directly over and the type is not
308284 // a named struct, then the type is usable as-is.
@@ -350,8 +326,17 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
350326 return *Entry = Ty;
351327 }
352328
353- StructType *DTy = StructType::create (Ty->getContext ());
354- finishType (DTy, STy, ElementTypes);
329+ StructType *DTy =
330+ StructType::create (Ty->getContext (), ElementTypes, " " , STy->isPacked ());
331+
332+ // Steal STy's name.
333+ if (STy->hasName ()) {
334+ SmallString<16 > TmpName = STy->getName ();
335+ STy->setName (" " );
336+ DTy->setName (TmpName);
337+ }
338+
339+ DstStructTypesSet.addNonOpaque (DTy);
355340 return *Entry = DTy;
356341 }
357342 }
0 commit comments