forked from OSchip/llvm-project
Make sure to remove all dead type names from the symbol table, not just
struct types. This fixes Regression/CodeGen/CBackend/2005-03-08-RecursiveTypeCrash.ll, a crash on Java output that Alkis reported. llvm-svn: 20519
This commit is contained in:
parent
7c303235b4
commit
ea50620eec
|
@ -227,20 +227,19 @@ bool CBackendNameAllUsedStructs::runOnModule(Module &M) {
|
||||||
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
|
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
|
||||||
|
|
||||||
// Loop over the module symbol table, removing types from UT that are
|
// Loop over the module symbol table, removing types from UT that are
|
||||||
// already named, and removing names for structure types that are not used.
|
// already named, and removing names for types that are not used.
|
||||||
//
|
//
|
||||||
SymbolTable &MST = M.getSymbolTable();
|
SymbolTable &MST = M.getSymbolTable();
|
||||||
for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
|
for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
|
||||||
TI != TE; ) {
|
TI != TE; ) {
|
||||||
SymbolTable::type_iterator I = TI++;
|
SymbolTable::type_iterator I = TI++;
|
||||||
if (const StructType *STy = dyn_cast<StructType>(I->second)) {
|
|
||||||
// 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(STy);
|
std::set<const Type *>::iterator UTI = UT.find(I->second);
|
||||||
if (UTI == UT.end())
|
if (UTI == UT.end())
|
||||||
MST.remove(I);
|
MST.remove(I);
|
||||||
else
|
else
|
||||||
UT.erase(UTI);
|
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
|
||||||
|
|
Loading…
Reference in New Issue