-//===- FindUsedTypes.h - Find all Types used by a module --------------------=//
+//===- FindUsedTypes.cpp - Find all Types used by a module ------------------=//
//
// This pass is used to seek out all of the types in use by the program.
//
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Assembly/CachedWriter.h"
#include "llvm/SymbolTable.h"
-#include "llvm/GlobalVariable.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Support/InstIterator.h"
AnalysisID FindUsedTypes::ID(AnalysisID::create<FindUsedTypes>());
AnalysisID FindUsedTypes::IncludeSymbolTableID(AnalysisID::create<FindUsedTypes>());
assert(0 && "Unimp");
}
-// doPerMethodWork - This incorporates all types used by the specified method
+// 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...
- if (IncludeSymbolTables && m->hasSymbolTable())
- IncorporateSymbolTable(m->getSymbolTable()); // Add symtab first...
+ if (IncludeSymbolTables && m.hasSymbolTable())
+ IncorporateSymbolTable(m.getSymbolTable()); // Add symtab first...
// Loop over global variables, incorporating their types
- for (Module::const_giterator I = m->gbegin(), E = m->gend(); I != E; ++I)
- IncorporateType((*I)->getType());
+ for (Module::const_giterator I = m.gbegin(), E = m.gend(); I != E; ++I)
+ IncorporateType(I->getType());
- for (Module::iterator MI = m->begin(), ME = m->end(); MI != ME; ++MI) {
- const Method *M = *MI;
- if (IncludeSymbolTables && M->hasSymbolTable())
- IncorporateSymbolTable(M->getSymbolTable()); // Add symtab first...
+ for (Module::iterator MI = m.begin(), ME = m.end(); MI != ME; ++MI) {
+ const Function &F = *MI;
+ if (IncludeSymbolTables && F.hasSymbolTable())
+ IncorporateSymbolTable(F.getSymbolTable()); // Add symtab first...
- // Loop over all of the instructions in the method, adding their return type
- // as well as the types of their operands.
+ // Loop over all of the instructions in the function, adding their return
+ // type as well as the types of their operands.
//
- for (Method::const_inst_iterator II = M->inst_begin(), IE = M->inst_end();
+ for (const_inst_iterator II = inst_begin(F), IE = inst_end(F);
II != IE; ++II) {
const Instruction *I = *II;
const Type *Ty = I->getType();
E = UsedTypes.end(); I != E; ++I)
o << " " << *I << "\n";
}
-
-// getAnalysisUsageInfo - Of course, we provide ourself...
-//
-void FindUsedTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
- Provided.push_back(FindUsedTypes::ID);
-}