MEGAPATCH checkin.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2778 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp
index fdf8f3e..141361d1 100644
--- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp
+++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp
@@ -61,13 +61,13 @@
 
     const char *getPassName() const { return "Emit Bytecode to Sparc Assembly";}
 
-    virtual bool run(Module *M) {
+    virtual bool run(Module &M) {
       // Write bytecode out to the sparc assembly stream
       Out << "\n\n!LLVM BYTECODE OUTPUT\n\t.section \".rodata\"\n\t.align 8\n";
       Out << "\t.global LLVMBytecode\n\t.type LLVMBytecode,#object\n";
       Out << "LLVMBytecode:\n";
       osparcasmstream OS(Out);
-      WriteBytecodeToFile(M, OS);
+      WriteBytecodeToFile(&M, OS);
 
       Out << ".end_LLVMBytecode:\n";
       Out << "\t.size LLVMBytecode, .end_LLVMBytecode-LLVMBytecode\n\n";
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index 4a08c24..a95f1e3 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -25,7 +25,6 @@
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
 #include "llvm/Constant.h"
-#include "llvm/BasicBlock.h"
 #include "llvm/Type.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "Support/STLExtras.h"
@@ -188,10 +187,9 @@
 
 InstrForest::InstrForest(Function *F)
 {
-  for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) {
-    BasicBlock *BB = *FI;
-    for_each(BB->begin(), BB->end(),
-             bind_obj(this, &InstrForest::buildTreeForInstruction));
+  for (Function::iterator BB = F->begin(), FE = F->end(); BB != FE; ++BB) {
+    for(BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+      buildTreeForInstruction(I);
   }
 }
 
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
index 614c5f6..b27f902 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
@@ -123,14 +123,10 @@
   // Record instructions in the vector for each basic block
   // 
   for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
-    {
-      MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec();
-      for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
-	{
-	  MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(*II);
-	  for (unsigned i=0; i < mvec.size(); i++)
-	    bbMvec.push_back(mvec[i]);
-	}
+    for (BasicBlock::iterator II = BI->begin(); II != BI->end(); ++II) {
+      MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(II);
+      for (unsigned i=0; i < mvec.size(); i++)
+        BI->getMachineInstrVec().push_back(mvec[i]);
     }
 
   // Insert phi elimination code -- added by Ruchira
@@ -191,49 +187,38 @@
 {
   // for all basic blocks in function
   //
-  for (Function::iterator BI = F->begin(); BI != F->end(); ++BI) {
-
-    BasicBlock *BB = *BI;
-    const BasicBlock::InstListType &InstList = BB->getInstList();
-    BasicBlock::InstListType::const_iterator  IIt = InstList.begin();
-
-    // for all instructions in the basic block
-    //
-    for( ; IIt != InstList.end(); ++IIt ) {
-
-      if (PHINode *PN = dyn_cast<PHINode>(*IIt)) {
-        // FIXME: This is probably wrong...
-	Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
+  for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
+    BasicBlock::InstListType &InstList = BB->getInstList();
+    for (BasicBlock::iterator IIt = InstList.begin();
+         PHINode *PN = dyn_cast<PHINode>(&*IIt); ++IIt) {
+      // FIXME: This is probably wrong...
+      Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
         
-	// for each incoming value of the phi, insert phi elimination
-	//
-        for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i)
-          { // insert the copy instruction to the predecessor BB
-            vector<MachineInstr*> mvec, CpVec;
-            target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
-                                              mvec);
-            for (vector<MachineInstr*>::iterator MI=mvec.begin();
-                 MI != mvec.end(); ++MI)
-              {
-                vector<MachineInstr*> CpVec2 =
-                  FixConstantOperandsForInstr(PN, *MI, target);
-                CpVec2.push_back(*MI);
-                CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
-              }
-            
-            InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
-          }
+      // for each incoming value of the phi, insert phi elimination
+      //
+      for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) {
+        // insert the copy instruction to the predecessor BB
+        vector<MachineInstr*> mvec, CpVec;
+        target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
+                                          mvec);
+        for (vector<MachineInstr*>::iterator MI=mvec.begin();
+             MI != mvec.end(); ++MI) {
+          vector<MachineInstr*> CpVec2 =
+            FixConstantOperandsForInstr(PN, *MI, target);
+          CpVec2.push_back(*MI);
+          CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
+        }
         
-        vector<MachineInstr*> mvec;
-        target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
-        
-	// get an iterator to machine instructions in the BB
-	MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
-
-	bbMvec.insert( bbMvec.begin(), mvec.begin(), mvec.end());
+        InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
       }
-      else break;   // since PHI nodes can only be at the top
       
+      vector<MachineInstr*> mvec;
+      target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
+      
+      // get an iterator to machine instructions in the BB
+      MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
+      
+      bbMvec.insert(bbMvec.begin(), mvec.begin(), mvec.end());
     }  // for each Phi Instr in BB
   } // for all BBs in function
 }
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index db5b6cd..b0eb21e 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -68,19 +68,19 @@
     : idTable(0), toAsm(os), Target(T), CurSection(Unknown) {}
   
   // (start|end)(Module|Function) - Callback methods to be invoked by subclasses
-  void startModule(Module *M) {
+  void startModule(Module &M) {
     // Create the global id table if it does not already exist
-    idTable = (GlobalIdTable*) M->getAnnotation(GlobalIdTable::AnnotId);
+    idTable = (GlobalIdTable*)M.getAnnotation(GlobalIdTable::AnnotId);
     if (idTable == NULL) {
-      idTable = new GlobalIdTable(M);
-      M->addAnnotation(idTable);
+      idTable = new GlobalIdTable(&M);
+      M.addAnnotation(idTable);
     }
   }
-  void startFunction(Function *F) {
+  void startFunction(Function &F) {
     // Make sure the slot table has information about this function...
-    idTable->Table.incorporateFunction(F);
+    idTable->Table.incorporateFunction(&F);
   }
-  void endFunction(Function *F) {
+  void endFunction(Function &) {
     idTable->Table.purgeFunction();  // Forget all about F
   }
   void endModule() {
@@ -194,19 +194,19 @@
     return "Output Sparc Assembly for Functions";
   }
 
-  virtual bool doInitialization(Module *M) {
+  virtual bool doInitialization(Module &M) {
     startModule(M);
     return false;
   }
 
-  virtual bool runOnFunction(Function *F) {
+  virtual bool runOnFunction(Function &F) {
     startFunction(F);
     emitFunction(F);
     endFunction(F);
     return false;
   }
 
-  virtual bool doFinalization(Module *M) {
+  virtual bool doFinalization(Module &M) {
     endModule();
     return false;
   }
@@ -215,7 +215,7 @@
     AU.setPreservesAll();
   }
 
-  void emitFunction(const Function *F);
+  void emitFunction(const Function &F);
 private :
   void emitBasicBlock(const BasicBlock *BB);
   void emitMachineInst(const MachineInstr *MI);
@@ -385,9 +385,9 @@
 }
 
 void
-SparcFunctionAsmPrinter::emitFunction(const Function *M)
+SparcFunctionAsmPrinter::emitFunction(const Function &F)
 {
-  string methName = getID(M);
+  string methName = getID(&F);
   toAsm << "!****** Outputing Function: " << methName << " ******\n";
   enterSection(AsmPrinter::Text);
   toAsm << "\t.align\t4\n\t.global\t" << methName << "\n";
@@ -396,8 +396,8 @@
   toAsm << methName << ":\n";
 
   // Output code for all of the basic blocks in the function...
-  for (Function::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
-    emitBasicBlock(*I);
+  for (Function::const_iterator I = F.begin(), E = F.end(); I != E; ++I)
+    emitBasicBlock(I);
 
   // Output a .size directive so the debugger knows the extents of the function
   toAsm << ".EndOf_" << methName << ":\n\t.size "
@@ -431,7 +431,7 @@
 
   const char *getPassName() const { return "Output Sparc Assembly for Module"; }
 
-  virtual bool run(Module *M) {
+  virtual bool run(Module &M) {
     startModule(M);
     emitGlobalsAndConstants(M);
     endModule();
@@ -443,14 +443,14 @@
   }
 
 private:
-  void emitGlobalsAndConstants(const Module *M);
+  void emitGlobalsAndConstants(const Module &M);
 
   void printGlobalVariable(const GlobalVariable *GV);
   void printSingleConstant(   const Constant* CV);
   void printConstantValueOnly(const Constant* CV);
   void printConstant(         const Constant* CV, std::string valID = "");
 
-  static void FoldConstants(const Module *M,
+  static void FoldConstants(const Module &M,
                             std::hash_set<const Constant*> &moduleConstants);
 };
 
@@ -716,12 +716,12 @@
 }
 
 
-void SparcModuleAsmPrinter::FoldConstants(const Module *M,
+void SparcModuleAsmPrinter::FoldConstants(const Module &M,
                                           std::hash_set<const Constant*> &MC) {
-  for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
-    if (!(*I)->isExternal()) {
+  for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
+    if (!I->isExternal()) {
       const std::hash_set<const Constant*> &pool =
-        MachineCodeForMethod::get(*I).getConstantPoolValues();
+        MachineCodeForMethod::get(I).getConstantPoolValues();
       MC.insert(pool.begin(), pool.end());
     }
 }
@@ -743,7 +743,7 @@
 }
 
 
-void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module *M) {
+void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module &M) {
   // First, get the constants there were marked by the code generator for
   // inclusion in the assembly code data area and fold them all into a
   // single constant pool since there may be lots of duplicates.  Also,
@@ -758,9 +758,9 @@
   
   // Section 1 : Read-only data section (implies initialized)
   enterSection(AsmPrinter::ReadOnlyData);
-  for (Module::const_giterator GI=M->gbegin(), GE=M->gend(); GI != GE; ++GI)
-    if ((*GI)->hasInitializer() && (*GI)->isConstant())
-      printGlobalVariable(*GI);
+  for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
+    if (GI->hasInitializer() && GI->isConstant())
+      printGlobalVariable(GI);
   
   for (std::hash_set<const Constant*>::const_iterator
          I = moduleConstants.begin(),
@@ -769,15 +769,15 @@
   
   // Section 2 : Initialized read-write data section
   enterSection(AsmPrinter::InitRWData);
-  for (Module::const_giterator GI=M->gbegin(), GE=M->gend(); GI != GE; ++GI)
-    if ((*GI)->hasInitializer() && ! (*GI)->isConstant())
-      printGlobalVariable(*GI);
+  for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
+    if (GI->hasInitializer() && !GI->isConstant())
+      printGlobalVariable(GI);
   
   // Section 3 : Uninitialized read-write data section
   enterSection(AsmPrinter::UninitRWData);
-  for (Module::const_giterator GI=M->gbegin(), GE=M->gend(); GI != GE; ++GI)
-    if (! (*GI)->hasInitializer())
-      printGlobalVariable(*GI);
+  for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
+    if (!GI->hasInitializer())
+      printGlobalVariable(GI);
   
   toAsm << "\n";
 }
diff --git a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp
index b42e777..7243149 100644
--- a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp
+++ b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp
@@ -20,26 +20,25 @@
 #include "llvm/Instruction.h"
 
 namespace {
-
-class InsertPrologEpilogCode : public FunctionPass {
-  TargetMachine &Target;
-public:
-  InsertPrologEpilogCode(TargetMachine &T) : Target(T) {}
-
-  const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; }
-
-  bool runOnFunction(Function *F) {
-    MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(F);
-    if (!mcodeInfo.isCompiledAsLeafMethod()) {
-      InsertPrologCode(F);
-      InsertEpilogCode(F);
+  class InsertPrologEpilogCode : public FunctionPass {
+    TargetMachine &Target;
+  public:
+    InsertPrologEpilogCode(TargetMachine &T) : Target(T) {}
+    
+    const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; }
+    
+    bool runOnFunction(Function &F) {
+      MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(&F);
+      if (!mcodeInfo.isCompiledAsLeafMethod()) {
+        InsertPrologCode(F);
+        InsertEpilogCode(F);
+      }
+      return false;
     }
-    return false;
-  }
-
-  void InsertPrologCode(Function *F);
-  void InsertEpilogCode(Function *F);
-};
+    
+    void InsertPrologCode(Function &F);
+    void InsertEpilogCode(Function &F);
+  };
 
 }  // End anonymous namespace
 
@@ -51,10 +50,8 @@
 //   Create prolog and epilog code for procedure entry and exit
 //------------------------------------------------------------------------ 
 
-void InsertPrologEpilogCode::InsertPrologCode(Function *F)
+void InsertPrologEpilogCode::InsertPrologCode(Function &F)
 {
-  BasicBlock *entryBB = F->getEntryNode();
-
   vector<MachineInstr*> mvec;
   MachineInstr* M;
   const MachineFrameInfo& frameInfo = Target.getFrameInfo();
@@ -64,7 +61,7 @@
   // We will assume that local register `l0' is unused since the SAVE
   // instruction must be the first instruction in each procedure.
   // 
-  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(F);
+  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(&F);
   unsigned int staticStackSize = mcInfo.getStaticStackSize();
   
   if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize())
@@ -104,26 +101,23 @@
       mvec.push_back(M);
     }
 
-  MachineCodeForBasicBlock& bbMvec = entryBB->getMachineInstrVec();
-  bbMvec.insert(entryBB->getMachineInstrVec().begin(),
-                mvec.begin(), mvec.end());
+  MachineCodeForBasicBlock& bbMvec = F.getEntryNode().getMachineInstrVec();
+  bbMvec.insert(bbMvec.begin(), mvec.begin(), mvec.end());
 }
 
-void InsertPrologEpilogCode::InsertEpilogCode(Function *F)
+void InsertPrologEpilogCode::InsertEpilogCode(Function &F)
 {
-  for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
-    Instruction *TermInst = (Instruction*)(*I)->getTerminator();
+  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+    Instruction *TermInst = (Instruction*)I->getTerminator();
     if (TermInst->getOpcode() == Instruction::Ret)
       {
-        BasicBlock* exitBB = *I;
-
         MachineInstr *Restore = new MachineInstr(RESTORE);
         Restore->SetMachineOperandReg(0, Target.getRegInfo().getZeroRegNum());
         Restore->SetMachineOperandConst(1, MachineOperand::MO_SignExtendedImmed,
                                         (int64_t)0);
         Restore->SetMachineOperandReg(2, Target.getRegInfo().getZeroRegNum());
         
-        MachineCodeForBasicBlock& bbMvec = exitBB->getMachineInstrVec();
+        MachineCodeForBasicBlock& bbMvec = I->getMachineInstrVec();
         MachineCodeForInstruction &termMvec =
           MachineCodeForInstruction::get(TermInst);
         
diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp
index a86e4f9..6aa4d81 100644
--- a/lib/Target/SparcV9/SparcV9RegInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp
@@ -286,29 +286,26 @@
   // check if this is a varArgs function. needed for choosing regs.
   bool isVarArgs = isVarArgsFunction(Meth->getType());
   
-  // get the argument list
-  const Function::ArgumentListType& ArgList = Meth->getArgumentList();
-  
   // for each argument.  count INT and FP arguments separately.
-  for( unsigned argNo=0, intArgNo=0, fpArgNo=0;
-       argNo != ArgList.size(); ++argNo)
-    {
-      // get the LR of arg
-      LiveRange *LR = LRI.getLiveRangeForValue((const Value *)ArgList[argNo]); 
-      assert( LR && "No live range found for method arg");
-      
-      unsigned regType = getRegType( LR );
-      unsigned regClassIDOfArgReg = MAXINT; // reg class of chosen reg (unused)
-      
-      int regNum = (regType == IntRegType)
-        ? regNumForIntArg(/*inCallee*/ true, isVarArgs,
-                          argNo, intArgNo++, fpArgNo, regClassIDOfArgReg)
-        : regNumForFPArg(regType, /*inCallee*/ true, isVarArgs,
-                         argNo, intArgNo, fpArgNo++, regClassIDOfArgReg); 
-      
-      if(regNum != InvalidRegNum)
-        LR->setSuggestedColor(regNum);
-    }
+  unsigned argNo=0, intArgNo=0, fpArgNo=0;
+  for(Function::const_aiterator I = Meth->abegin(), E = Meth->aend();
+      I != E; ++I, ++argNo) {
+    // get the LR of arg
+    LiveRange *LR = LRI.getLiveRangeForValue(I);
+    assert(LR && "No live range found for method arg");
+    
+    unsigned regType = getRegType(LR);
+    unsigned regClassIDOfArgReg = MAXINT; // reg class of chosen reg (unused)
+    
+    int regNum = (regType == IntRegType)
+      ? regNumForIntArg(/*inCallee*/ true, isVarArgs,
+                        argNo, intArgNo++, fpArgNo, regClassIDOfArgReg)
+      : regNumForFPArg(regType, /*inCallee*/ true, isVarArgs,
+                       argNo, intArgNo, fpArgNo++, regClassIDOfArgReg); 
+    
+    if(regNum != InvalidRegNum)
+      LR->setSuggestedColor(regNum);
+  }
 }
 
 
@@ -323,16 +320,15 @@
 
   // check if this is a varArgs function. needed for choosing regs.
   bool isVarArgs = isVarArgsFunction(Meth->getType());
-                                                 // get the argument list
-  const Function::ArgumentListType& ArgList = Meth->getArgumentList();
-                                                 // get an iterator to arg list
   MachineInstr *AdMI;
 
   // for each argument
-  for( unsigned argNo=0, intArgNo=0, fpArgNo=0;
-       argNo != ArgList.size(); ++argNo) {    
+  // for each argument.  count INT and FP arguments separately.
+  unsigned argNo=0, intArgNo=0, fpArgNo=0;
+  for(Function::const_aiterator I = Meth->abegin(), E = Meth->aend();
+      I != E; ++I, ++argNo) {
     // get the LR of arg
-    LiveRange *LR = LRI.getLiveRangeForValue((Value*)ArgList[argNo]); 
+    LiveRange *LR = LRI.getLiveRangeForValue(I);
     assert( LR && "No live range found for method arg");
 
     unsigned regType = getRegType( LR );
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index fecdf23..be6e9f4 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -135,8 +135,8 @@
     return "Sparc ConstructMachineCodeForFunction";
   }
 
-  bool runOnFunction(Function *F) {
-    MachineCodeForMethod::construct(F, Target);
+  bool runOnFunction(Function &F) {
+    MachineCodeForMethod::construct(&F, Target);
     return false;
   }
 };
@@ -147,9 +147,9 @@
   inline InstructionSelection(TargetMachine &T) : Target(T) {}
   const char *getPassName() const { return "Sparc Instruction Selection"; }
 
-  bool runOnFunction(Function *F) {
-    if (SelectInstructionsForMethod(F, Target)) {
-      cerr << "Instr selection failed for function " << F->getName() << "\n";
+  bool runOnFunction(Function &F) {
+    if (SelectInstructionsForMethod(&F, Target)) {
+      cerr << "Instr selection failed for function " << F.getName() << "\n";
       abort();
     }
     return false;
@@ -159,20 +159,17 @@
 struct FreeMachineCodeForFunction : public FunctionPass {
   const char *getPassName() const { return "Sparc FreeMachineCodeForFunction"; }
 
-  static void freeMachineCode(Instruction *I) {
-    MachineCodeForInstruction::destroy(I);
+  static void freeMachineCode(Instruction &I) {
+    MachineCodeForInstruction::destroy(&I);
   }
   
-  bool runOnFunction(Function *F) {
-    for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
-      for (BasicBlock::iterator I = (*FI)->begin(), E = (*FI)->end();
-           I != E; ++I)
-        MachineCodeForInstruction::get(*I).dropAllReferences();
+  bool runOnFunction(Function &F) {
+    for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
+      for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E; ++I)
+        MachineCodeForInstruction::get(I).dropAllReferences();
     
-    for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
-      for (BasicBlock::iterator I = (*FI)->begin(), E = (*FI)->end();
-           I != E; ++I)
-        freeMachineCode(*I);
+    for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
+      for_each(FI->begin(), FI->end(), freeMachineCode);
     
     return false;
   }