diff options
author | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
commit | 0b12b5f50ec77a8bd01b92d287c52d748619bb4b (patch) | |
tree | 5764db59facb124b023f1de96f0e45d37657c82e /lib/Target | |
parent | 18961504fc2b299578dba817900a0696cf3ccc4d (diff) | |
download | external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.zip external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.gz external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.bz2 |
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
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 4 | ||||
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 8 | ||||
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrSelection.cpp | 79 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 64 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp | 58 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9RegInfo.cpp | 52 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9TargetMachine.cpp | 29 |
7 files changed, 132 insertions, 162 deletions
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 @@ namespace { 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 @@ LabelNode::dumpNode(int indent) const 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 @@ SelectInstructionsForMethod(Function *F, TargetMachine &target) // 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 @@ InsertCode4AllPhisInMeth(Function *F, TargetMachine &target) { // 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 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 (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:"); - vector<MachineInstr*> mvec; - target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec); + // 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()); + } - // 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 @@ public: : 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 @@ struct SparcFunctionAsmPrinter : public FunctionPass, public AsmPrinter { 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 @@ struct SparcFunctionAsmPrinter : public FunctionPass, public AsmPrinter { 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 @@ SparcFunctionAsmPrinter::emitBasicBlock(const BasicBlock *BB) } 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 @@ SparcFunctionAsmPrinter::emitFunction(const Function *M) 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 @@ public: 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 @@ public: } 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 @@ SparcModuleAsmPrinter::printConstant(const Constant* CV, string valID) } -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::printGlobalVariable(const GlobalVariable* GV) } -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 @@ void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module *M) { // 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 @@ void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module *M) { // 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 @@ public: // 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 @@ void InsertPrologEpilogCode::InsertPrologCode(Function *F) // 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 @@ void InsertPrologEpilogCode::InsertPrologCode(Function *F) 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 @@ void UltraSparcRegInfo::suggestRegs4MethodArgs(const Function *Meth, // 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 @@ void UltraSparcRegInfo::colorMethodArgs(const Function *Meth, // 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 @@ public: 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 @@ public: 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 @@ public: 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; } |