[llvm-commits] [llvm] r65742 - /llvm/trunk/lib/VMCore/AsmWriter.cpp

Chris Lattner sabre at nondot.org
Sat Feb 28 16:32:33 PST 2009


Author: lattner
Date: Sat Feb 28 18:32:33 2009
New Revision: 65742

URL: http://llvm.org/viewvc/llvm-project?rev=65742&view=rev
Log:
walk type symbol table also, so we get:

	type opaque		; type %0
	%C = type { %0, %0 }

instead of:

	%C = type { opaque, opaque }

when appropriate.


Modified:
    llvm/trunk/lib/VMCore/AsmWriter.cpp

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=65742&r1=65741&r2=65742&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Sat Feb 28 18:32:33 2009
@@ -332,6 +332,13 @@
       : TP(tp), NumberedTypes(numberedTypes) {}
     
     void Run(const Module &M) {
+      // Get types from the type symbol table.  This gets opaque types referened
+      // only through derived named types.
+      const TypeSymbolTable &ST = M.getTypeSymbolTable();
+      for (TypeSymbolTable::const_iterator TI = ST.begin(), E = ST.end();
+           TI != E; ++TI)
+        IncorporateType(TI->second);
+      
       // Get types from global variables.
       for (Module::const_global_iterator I = M.global_begin(),
            E = M.global_end(); I != E; ++I) {
@@ -368,11 +375,12 @@
   private:
     void IncorporateType(const Type *Ty) {
       // Check to see if we're already visited this type.
-      if (!VisitedTypes.insert(Ty).second || TP.hasTypeName(Ty))
+      if (!VisitedTypes.insert(Ty).second)
         return;
       
       // If this is a structure or opaque type, add a name for the type.
-      if (isa<StructType>(Ty) || isa<OpaqueType>(Ty)) {
+      if ((isa<StructType>(Ty) || isa<OpaqueType>(Ty))
+          && !TP.hasTypeName(Ty)) {
         TP.addTypeName(Ty, "%"+utostr(unsigned(NumberedTypes.size())));
         NumberedTypes.push_back(Ty);
       }





More information about the llvm-commits mailing list