MEGAPATCH checkin.

For details, See: docs/2002-06-25-MegaPatchInfo.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index c84719f..1c61ff3 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -95,31 +95,30 @@
   }
 
   // Look for an indirect method call...
-  for (Function::iterator BBI = M->begin(), BBE = M->end(); BBI != BBE; ++BBI) {
-    BasicBlock *BB = *BBI;
+  for (Function::iterator BB = M->begin(), BBE = M->end(); BB != BBE; ++BB)
     for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){
-      Instruction *I = *II;
+      Instruction &I = *II;
 
-      if (CallInst *CI = dyn_cast<CallInst>(I)) {
+      if (CallInst *CI = dyn_cast<CallInst>(&I)) {
         if (CI->getCalledFunction() == 0)
           Node->addCalledMethod(ExternalNode);
-      } else if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
+      } else if (InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
         if (II->getCalledFunction() == 0)
           Node->addCalledMethod(ExternalNode);
       }
     }
-  }
 }
 
-bool CallGraph::run(Module *TheModule) {
+bool CallGraph::run(Module &M) {
   destroy();
 
-  Mod = TheModule;
+  Mod = &M;
   ExternalNode = getNodeFor(0);
   Root = 0;
 
   // Add every method to the call graph...
-  for_each(Mod->begin(), Mod->end(), bind_obj(this,&CallGraph::addToCallGraph));
+  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+    addToCallGraph(I);
 
   // If we didn't find a main method, use the external call graph node
   if (Root == 0) Root = ExternalNode;
diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
index 1723a8e..8cad60d 100644
--- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
+++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
@@ -19,7 +19,6 @@
 #include "llvm/Analysis/FindUnsafePointerTypes.h"
 #include "llvm/Assembly/CachedWriter.h"
 #include "llvm/Type.h"
-#include "llvm/Instruction.h"
 #include "llvm/Module.h"
 #include "llvm/Support/InstIterator.h"
 #include "Support/CommandLine.h"
@@ -50,21 +49,20 @@
 }
 
 
-bool FindUnsafePointerTypes::run(Module *Mod) {
-  for (Module::iterator MI = Mod->begin(), ME = Mod->end();
-       MI != ME; ++MI) {
-    const Function *M = *MI;  // We don't need/want write access
-    for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
-      const Instruction *Inst = *I;
-      const Type *ITy = Inst->getType();
+bool FindUnsafePointerTypes::run(Module &Mod) {
+  for (Module::iterator FI = Mod.begin(), E = Mod.end();
+       FI != E; ++FI) {
+    const Function *F = FI;  // We don't need/want write access
+    for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
+      const Type *ITy = I->getType();
       if (isa<PointerType>(ITy) && !UnsafeTypes.count((PointerType*)ITy))
-        if (!isSafeInstruction(Inst)) {
+        if (!isSafeInstruction(*I)) {
           UnsafeTypes.insert((PointerType*)ITy);
 
           if (PrintFailures) {
-            CachedWriter CW(M->getParent(), std::cerr);
+            CachedWriter CW(F->getParent(), std::cerr);
             CW << "FindUnsafePointerTypes: Type '" << ITy
-               << "' marked unsafe in '" << M->getName() << "' by:\n" << Inst;
+               << "' marked unsafe in '" << F->getName() << "' by:\n" << **I;
           }
         }
     }
diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp
index b4897a2..8cfe108 100644
--- a/lib/Analysis/IPA/FindUsedTypes.cpp
+++ b/lib/Analysis/IPA/FindUsedTypes.cpp
@@ -7,10 +7,8 @@
 #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/Instruction.h"
 #include "llvm/Support/InstIterator.h"
 
 AnalysisID FindUsedTypes::ID(AnalysisID::create<FindUsedTypes>());
@@ -42,25 +40,25 @@
 
 // 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 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;
+    if (IncludeSymbolTables && F.hasSymbolTable())
+      IncorporateSymbolTable(F.getSymbolTable()); // Add symtab first...
   
     // 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();