forked from OSchip/llvm-project
Fix bug: CBackend/2003-10-23-UnusedType.ll and hopefully 252.eon
llvm-svn: 9441
This commit is contained in:
parent
70a3b9024e
commit
fb8e19b7ca
|
|
@ -41,12 +41,22 @@ void FindUsedTypes::IncorporateType(const Type *Ty) {
|
||||||
IncorporateType(*I);
|
IncorporateType(*I);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FindUsedTypes::IncorporateSymbolTable(const SymbolTable &ST) {
|
||||||
|
SymbolTable::const_iterator TI = ST.find(Type::TypeTy);
|
||||||
|
if (TI == ST.end()) return; // No named types
|
||||||
|
|
||||||
|
for (SymbolTable::type_const_iterator I = TI->second.begin(),
|
||||||
|
E = TI->second.end(); I != E; ++I)
|
||||||
|
IncorporateType(cast<Type>(I->second));
|
||||||
|
}
|
||||||
|
|
||||||
// run - This incorporates all types used by the specified module
|
// run - This incorporates all types used by the specified module
|
||||||
//
|
//
|
||||||
bool FindUsedTypes::run(Module &m) {
|
bool FindUsedTypes::run(Module &m) {
|
||||||
UsedTypes.clear(); // reset if run multiple times...
|
UsedTypes.clear(); // reset if run multiple times...
|
||||||
|
|
||||||
|
IncorporateSymbolTable(m.getSymbolTable());
|
||||||
|
|
||||||
// Loop over global variables, incorporating their types
|
// Loop over global variables, incorporating their types
|
||||||
for (Module::const_giterator I = m.gbegin(), E = m.gend(); I != E; ++I)
|
for (Module::const_giterator I = m.gbegin(), E = m.gend(); I != E; ++I)
|
||||||
IncorporateType(I->getType());
|
IncorporateType(I->getType());
|
||||||
|
|
@ -54,6 +64,7 @@ bool FindUsedTypes::run(Module &m) {
|
||||||
for (Module::iterator MI = m.begin(), ME = m.end(); MI != ME; ++MI) {
|
for (Module::iterator MI = m.begin(), ME = m.end(); MI != ME; ++MI) {
|
||||||
IncorporateType(MI->getType());
|
IncorporateType(MI->getType());
|
||||||
const Function &F = *MI;
|
const Function &F = *MI;
|
||||||
|
IncorporateSymbolTable(F.getSymbolTable());
|
||||||
|
|
||||||
// Loop over all of the instructions in the function, adding their return
|
// Loop over all of the instructions in the function, adding their return
|
||||||
// type as well as the types of their operands.
|
// type as well as the types of their operands.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue