* Add support for different "PassType's"
[oota-llvm.git] / lib / Analysis / IPA / FindUsedTypes.cpp
index 5c961d2bebe7b72d8e3fc04a4ca68514152460ae..1139cf3df8b96d644c569085e86ecc35648e3ab2 100644 (file)
@@ -7,15 +7,13 @@
 #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/Function.h"
-#include "llvm/Instruction.h"
 #include "llvm/Support/InstIterator.h"
 
+static RegisterAnalysis<FindUsedTypes>
+X("printusedtypes", "Find Used Types");
 AnalysisID FindUsedTypes::ID(AnalysisID::create<FindUsedTypes>());
-AnalysisID FindUsedTypes::IncludeSymbolTableID(AnalysisID::create<FindUsedTypes>());
 
 // IncorporateType - Incorporate one type and all of its subtypes into the
 // collection of used types.
@@ -34,34 +32,23 @@ void FindUsedTypes::IncorporateType(const Type *Ty) {
     IncorporateType(*I);
 }
 
-// IncorporateSymbolTable - Add all types referenced by the specified symtab
-// into the collection of used types.
-//
-void FindUsedTypes::IncorporateSymbolTable(const SymbolTable *ST) {
-  assert(0 && "Unimp");
-}
 
 // 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...
-
   // 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 Function *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;
   
     // Loop over all of the instructions in the function, adding their return
     // type as well as the types of their operands.
     //
-    for (const_inst_iterator II = inst_begin(M), IE = inst_end(M);
+    for (const_inst_iterator II = inst_begin(F), IE = inst_end(F);
          II != IE; ++II) {
       const Instruction *I = *II;
       const Type *Ty = I->getType();
@@ -81,7 +68,7 @@ bool FindUsedTypes::run(Module *m) {
 // passed in, then the types are printed symbolically if possible, using the
 // symbol table from the module.
 //
-void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const {
+void FindUsedTypes::printTypes(std::ostream &o, const Module *M) const {
   o << "Types in use by this module:\n";
   if (M) {
     CachedWriter CW(M, o);
@@ -93,11 +80,3 @@ void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const {
            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);
-}