mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Fix PR918 by only using typedefs to name struct types. This makes the later
type ordering stuff work better. This fixes PR918 and CodeGen/CBackend/2007-01-15-NamedArrayType.ll Patch by Gordon Henriksen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33254 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -270,6 +270,11 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) { | |||||||
|        TI != TE; ) { |        TI != TE; ) { | ||||||
|     TypeSymbolTable::iterator I = TI++; |     TypeSymbolTable::iterator I = TI++; | ||||||
|      |      | ||||||
|  |     // If this isn't a struct type, remove it from our set of types to name. | ||||||
|  |     // This simplifies emission later. | ||||||
|  |     if (!isa<StructType>(I->second)) { | ||||||
|  |       TST.remove(I); | ||||||
|  |     } else { | ||||||
|       // If this is not used, remove it from the symbol table. |       // If this is not used, remove it from the symbol table. | ||||||
|       std::set<const Type *>::iterator UTI = UT.find(I->second); |       std::set<const Type *>::iterator UTI = UT.find(I->second); | ||||||
|       if (UTI == UT.end()) |       if (UTI == UT.end()) | ||||||
| @@ -277,6 +282,7 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) { | |||||||
|       else |       else | ||||||
|         UT.erase(UTI);    // Only keep one name for this type. |         UT.erase(UTI);    // Only keep one name for this type. | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // UT now contains types that are not named.  Loop over it, naming |   // UT now contains types that are not named.  Loop over it, naming | ||||||
|   // structure types. |   // structure types. | ||||||
| @@ -1694,10 +1700,11 @@ void CWriter::printModuleTypes(const TypeSymbolTable &TST) { | |||||||
|  |  | ||||||
|   Out << '\n'; |   Out << '\n'; | ||||||
|  |  | ||||||
|   // Now we can print out typedefs... |   // Now we can print out typedefs.  Above, we guaranteed that this can only be | ||||||
|  |   // for struct types. | ||||||
|   Out << "/* Typedefs */\n"; |   Out << "/* Typedefs */\n"; | ||||||
|   for (I = TST.begin(); I != End; ++I) { |   for (I = TST.begin(); I != End; ++I) { | ||||||
|     const Type *Ty = cast<Type>(I->second); |     const StructType *Ty = cast<StructType>(I->second); | ||||||
|     std::string Name = "l_" + Mang->makeNameProper(I->first); |     std::string Name = "l_" + Mang->makeNameProper(I->first); | ||||||
|     Out << "typedef "; |     Out << "typedef "; | ||||||
|     printType(Out, Ty, false, Name); |     printType(Out, Ty, false, Name); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user