mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-04 18:06:49 +00:00
The "correct" fix for CBackend/2003-10-23-UnusedType.ll is to not even try
to emit types which are not used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9647 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ba12c23ca7
commit
fa395ec036
@ -36,6 +36,8 @@ namespace {
|
|||||||
std::ostream &Out;
|
std::ostream &Out;
|
||||||
Mangler *Mang;
|
Mangler *Mang;
|
||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
|
FindUsedTypes *FUT;
|
||||||
|
|
||||||
std::map<const Type *, std::string> TypeNames;
|
std::map<const Type *, std::string> TypeNames;
|
||||||
std::set<const Value*> MangledGlobals;
|
std::set<const Value*> MangledGlobals;
|
||||||
bool needsMalloc, emittedInvoke;
|
bool needsMalloc, emittedInvoke;
|
||||||
@ -52,6 +54,7 @@ namespace {
|
|||||||
virtual bool run(Module &M) {
|
virtual bool run(Module &M) {
|
||||||
// Initialize
|
// Initialize
|
||||||
TheModule = &M;
|
TheModule = &M;
|
||||||
|
FUT = &getAnalysis<FindUsedTypes>();
|
||||||
|
|
||||||
// Ensure that all structure types have names...
|
// Ensure that all structure types have names...
|
||||||
bool Changed = nameAllUsedStructureTypes(M);
|
bool Changed = nameAllUsedStructureTypes(M);
|
||||||
@ -542,7 +545,7 @@ void CWriter::writeOperand(Value *Operand) {
|
|||||||
//
|
//
|
||||||
bool CWriter::nameAllUsedStructureTypes(Module &M) {
|
bool CWriter::nameAllUsedStructureTypes(Module &M) {
|
||||||
// Get a set of types that are used by the program...
|
// Get a set of types that are used by the program...
|
||||||
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
|
std::set<const Type *> UT = FUT->getTypes();
|
||||||
|
|
||||||
// Loop over the module symbol table, removing types from UT that are already
|
// Loop over the module symbol table, removing types from UT that are already
|
||||||
// named.
|
// named.
|
||||||
@ -786,24 +789,28 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
// Print out forward declarations for structure types before anything else!
|
// Print out forward declarations for structure types before anything else!
|
||||||
Out << "/* Structure forward decls */\n";
|
Out << "/* Structure forward decls */\n";
|
||||||
for (; I != End; ++I)
|
for (; I != End; ++I)
|
||||||
if (const Type *STy = dyn_cast<StructType>(I->second)) {
|
if (const Type *STy = dyn_cast<StructType>(I->second))
|
||||||
std::string Name = "struct l_" + Mangler::makeNameProper(I->first);
|
// Only print out used types!
|
||||||
Out << Name << ";\n";
|
if (FUT->getTypes().count(STy)) {
|
||||||
TypeNames.insert(std::make_pair(STy, Name));
|
std::string Name = "struct l_" + Mangler::makeNameProper(I->first);
|
||||||
}
|
Out << Name << ";\n";
|
||||||
|
TypeNames.insert(std::make_pair(STy, Name));
|
||||||
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
// Now we can print out typedefs...
|
// Now we can print out typedefs...
|
||||||
Out << "/* Typedefs */\n";
|
Out << "/* Typedefs */\n";
|
||||||
for (I = ST.type_begin(Type::TypeTy); I != End; ++I) {
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
const Type *Ty = cast<Type>(I->second);
|
// Only print out used types!
|
||||||
std::string Name = "l_" + Mangler::makeNameProper(I->first);
|
if (FUT->getTypes().count(cast<Type>(I->second))) {
|
||||||
Out << "typedef ";
|
const Type *Ty = cast<Type>(I->second);
|
||||||
printType(Out, Ty, Name);
|
std::string Name = "l_" + Mangler::makeNameProper(I->first);
|
||||||
Out << ";\n";
|
Out << "typedef ";
|
||||||
}
|
printType(Out, Ty, Name);
|
||||||
|
Out << ";\n";
|
||||||
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
// Keep track of which structures have been printed so far...
|
// Keep track of which structures have been printed so far...
|
||||||
@ -815,7 +822,9 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
Out << "/* Structure contents */\n";
|
Out << "/* Structure contents */\n";
|
||||||
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
||||||
printContainedStructs(STy, StructPrinted);
|
// Only print out used types!
|
||||||
|
if (FUT->getTypes().count(STy))
|
||||||
|
printContainedStructs(STy, StructPrinted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the struct onto the stack and recursively push all structs
|
// Push the struct onto the stack and recursively push all structs
|
||||||
|
@ -36,6 +36,8 @@ namespace {
|
|||||||
std::ostream &Out;
|
std::ostream &Out;
|
||||||
Mangler *Mang;
|
Mangler *Mang;
|
||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
|
FindUsedTypes *FUT;
|
||||||
|
|
||||||
std::map<const Type *, std::string> TypeNames;
|
std::map<const Type *, std::string> TypeNames;
|
||||||
std::set<const Value*> MangledGlobals;
|
std::set<const Value*> MangledGlobals;
|
||||||
bool needsMalloc, emittedInvoke;
|
bool needsMalloc, emittedInvoke;
|
||||||
@ -52,6 +54,7 @@ namespace {
|
|||||||
virtual bool run(Module &M) {
|
virtual bool run(Module &M) {
|
||||||
// Initialize
|
// Initialize
|
||||||
TheModule = &M;
|
TheModule = &M;
|
||||||
|
FUT = &getAnalysis<FindUsedTypes>();
|
||||||
|
|
||||||
// Ensure that all structure types have names...
|
// Ensure that all structure types have names...
|
||||||
bool Changed = nameAllUsedStructureTypes(M);
|
bool Changed = nameAllUsedStructureTypes(M);
|
||||||
@ -542,7 +545,7 @@ void CWriter::writeOperand(Value *Operand) {
|
|||||||
//
|
//
|
||||||
bool CWriter::nameAllUsedStructureTypes(Module &M) {
|
bool CWriter::nameAllUsedStructureTypes(Module &M) {
|
||||||
// Get a set of types that are used by the program...
|
// Get a set of types that are used by the program...
|
||||||
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
|
std::set<const Type *> UT = FUT->getTypes();
|
||||||
|
|
||||||
// Loop over the module symbol table, removing types from UT that are already
|
// Loop over the module symbol table, removing types from UT that are already
|
||||||
// named.
|
// named.
|
||||||
@ -786,24 +789,28 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
// Print out forward declarations for structure types before anything else!
|
// Print out forward declarations for structure types before anything else!
|
||||||
Out << "/* Structure forward decls */\n";
|
Out << "/* Structure forward decls */\n";
|
||||||
for (; I != End; ++I)
|
for (; I != End; ++I)
|
||||||
if (const Type *STy = dyn_cast<StructType>(I->second)) {
|
if (const Type *STy = dyn_cast<StructType>(I->second))
|
||||||
std::string Name = "struct l_" + Mangler::makeNameProper(I->first);
|
// Only print out used types!
|
||||||
Out << Name << ";\n";
|
if (FUT->getTypes().count(STy)) {
|
||||||
TypeNames.insert(std::make_pair(STy, Name));
|
std::string Name = "struct l_" + Mangler::makeNameProper(I->first);
|
||||||
}
|
Out << Name << ";\n";
|
||||||
|
TypeNames.insert(std::make_pair(STy, Name));
|
||||||
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
// Now we can print out typedefs...
|
// Now we can print out typedefs...
|
||||||
Out << "/* Typedefs */\n";
|
Out << "/* Typedefs */\n";
|
||||||
for (I = ST.type_begin(Type::TypeTy); I != End; ++I) {
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
const Type *Ty = cast<Type>(I->second);
|
// Only print out used types!
|
||||||
std::string Name = "l_" + Mangler::makeNameProper(I->first);
|
if (FUT->getTypes().count(cast<Type>(I->second))) {
|
||||||
Out << "typedef ";
|
const Type *Ty = cast<Type>(I->second);
|
||||||
printType(Out, Ty, Name);
|
std::string Name = "l_" + Mangler::makeNameProper(I->first);
|
||||||
Out << ";\n";
|
Out << "typedef ";
|
||||||
}
|
printType(Out, Ty, Name);
|
||||||
|
Out << ";\n";
|
||||||
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
// Keep track of which structures have been printed so far...
|
// Keep track of which structures have been printed so far...
|
||||||
@ -815,7 +822,9 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
Out << "/* Structure contents */\n";
|
Out << "/* Structure contents */\n";
|
||||||
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
||||||
printContainedStructs(STy, StructPrinted);
|
// Only print out used types!
|
||||||
|
if (FUT->getTypes().count(STy))
|
||||||
|
printContainedStructs(STy, StructPrinted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the struct onto the stack and recursively push all structs
|
// Push the struct onto the stack and recursively push all structs
|
||||||
|
Loading…
Reference in New Issue
Block a user