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();
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index b3da95f..8637a1a 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -31,8 +31,8 @@
   if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
     return true;
   
-  Instruction *I = cast<Instruction>(V);
-  BasicBlock *BB = I->getParent();
+  const Instruction *I = cast<Instruction>(V);
+  const BasicBlock *BB = I->getParent();
 
   return !L->contains(BB);
 }
@@ -41,8 +41,8 @@
 InductionVariable::Classify(const Value *Start, const Value *Step,
 			    const Loop *L = 0) {
   // Check for cannonical and simple linear expressions now...
-  if (ConstantInt *CStart = dyn_cast<ConstantInt>(Start))
-    if (ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) {
+  if (const ConstantInt *CStart = dyn_cast<ConstantInt>(Start))
+    if (const ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) {
       if (CStart->equalsInt(0) && CStep->equalsInt(1))
 	return Cannonical;
       else
diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp
index 5dfccd2..8d0e34c 100644
--- a/lib/Analysis/IntervalPartition.cpp
+++ b/lib/Analysis/IntervalPartition.cpp
@@ -51,19 +51,17 @@
 // IntervalPartition ctor - Build the first level interval partition for the
 // specified function...
 //
-bool IntervalPartition::runOnFunction(Function *F) {
-  assert(F->front() && "Cannot operate on prototypes!");
-
+bool IntervalPartition::runOnFunction(Function &F) {
   // Pass false to intervals_begin because we take ownership of it's memory
-  function_interval_iterator I = intervals_begin(F, false);
-  assert(I != intervals_end(F) && "No intervals in function!?!?!");
+  function_interval_iterator I = intervals_begin(&F, false);
+  assert(I != intervals_end(&F) && "No intervals in function!?!?!");
 
   addIntervalToPartition(RootInterval = *I);
 
   ++I;  // After the first one...
 
   // Add the rest of the intervals to the partition...
-  for_each(I, intervals_end(F),
+  for_each(I, intervals_end(&F),
 	   bind_obj(this, &IntervalPartition::addIntervalToPartition));
 
   // Now that we know all of the successor information, propogate this to the
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 29558da..2559912 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -35,7 +35,7 @@
 //===----------------------------------------------------------------------===//
 // LoopInfo implementation
 //
-bool LoopInfo::runOnFunction(Function *F) {
+bool LoopInfo::runOnFunction(Function &) {
   releaseMemory();
   Calculate(getAnalysis<DominatorSet>());    // Update
   return false;
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index ca0b64a..caff1f1 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -21,7 +21,7 @@
 AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>(), true);
 AnalysisID DominatorSet::PostDomID(AnalysisID::create<DominatorSet>(), true);
 
-bool DominatorSet::runOnFunction(Function *F) {
+bool DominatorSet::runOnFunction(Function &F) {
   Doms.clear();   // Reset from the last time we were run...
 
   if (isPostDominator())
@@ -40,17 +40,17 @@
   
   // Loop through the basic block until we find A or B.
   BasicBlock::iterator I = BBA->begin();
-  for (; *I != A && *I != B; ++I) /*empty*/;
+  for (; &*I != A && &*I != B; ++I) /*empty*/;
   
   // A dominates B if it is found first in the basic block...
-  return *I == A;
+  return &*I == A;
 }
 
 // calcForwardDominatorSet - This method calculates the forward dominator sets
 // for the specified function.
 //
-void DominatorSet::calcForwardDominatorSet(Function *M) {
-  Root = M->getEntryNode();
+void DominatorSet::calcForwardDominatorSet(Function &F) {
+  Root = &F.getEntryNode();
   assert(pred_begin(Root) == pred_end(Root) &&
 	 "Root node has predecessors in function!");
 
@@ -59,7 +59,7 @@
     Changed = false;
 
     DomSetType WorkingSet;
-    df_iterator<Function*> It = df_begin(M), End = df_end(M);
+    df_iterator<Function*> It = df_begin(&F), End = df_end(&F);
     for ( ; It != End; ++It) {
       BasicBlock *BB = *It;
       pred_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
@@ -93,7 +93,7 @@
 // only have a single exit node (return stmt), then calculates the post
 // dominance sets for the function.
 //
-void DominatorSet::calcPostDominatorSet(Function *F) {
+void DominatorSet::calcPostDominatorSet(Function &F) {
   // Since we require that the unify all exit nodes pass has been run, we know
   // that there can be at most one return instruction in the function left.
   // Get it.
@@ -101,8 +101,8 @@
   Root = getAnalysis<UnifyFunctionExitNodes>().getExitNode();
 
   if (Root == 0) {  // No exit node for the function?  Postdomsets are all empty
-    for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
-      Doms[*FI] = DomSetType();
+    for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
+      Doms[FI] = DomSetType();
     return;
   }