diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 2cdca502dc64..40e0129db250 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -111,7 +111,8 @@ static void fillTypeNameTable(const Module *M, // const Type *Ty = cast(I->second); if (!isa(Ty) || - !cast(Ty)->getElementType()->isPrimitiveType()) + !cast(Ty)->getElementType()->isPrimitiveType() || + isa(cast(Ty)->getElementType())) TypeNames.insert(std::make_pair(Ty, getLLVMName(I->first))); } } @@ -122,12 +123,16 @@ static void fillTypeNameTable(const Module *M, static std::string calcTypeName(const Type *Ty, std::vector &TypeStack, std::map &TypeNames){ - if (Ty->isPrimitiveType()) return Ty->getDescription(); // Base case + if (Ty->isPrimitiveType() && !isa(Ty)) + return Ty->getDescription(); // Base case // Check to see if the type is named. std::map::iterator I = TypeNames.find(Ty); if (I != TypeNames.end()) return I->second; + if (isa(Ty)) + return "opaque"; + // Check to see if the Type is already on the stack... unsigned Slot = 0, CurSize = TypeStack.size(); while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type @@ -210,9 +215,6 @@ static std::ostream &printTypeInt(std::ostream &Out, const Type *Ty, std::map::iterator I = TypeNames.find(Ty); if (I != TypeNames.end()) return Out << I->second; - if (isa(Ty)) - return Out << "opaque"; - // Otherwise we have a type that has not been named but is a derived type. // Carefully recurse the type hierarchy to print out any contained symbolic // names.