diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-27 06:56:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-27 06:56:12 +0000 |
commit | f57b845547302d24ecb6a9e79d7bc386f761a6c9 (patch) | |
tree | 369bc5be013a3a6d0373dbf26820d701e01c5297 /lib | |
parent | f2361c5e5c2917e6f19a55927b221d8671753a40 (diff) | |
download | external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.zip external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.gz external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.bz2 |
* Rename MethodPass class to FunctionPass
- Rename runOnMethod to runOnFunction
* Transform getAnalysisUsageInfo into getAnalysisUsage
- Method is now const
- It now takes one AnalysisUsage object to fill in instead of 3 vectors
to fill in
- Pass's now specify which other passes they _preserve_ not which ones
they modify (be conservative!)
- A pass can specify that it preserves all analyses (because it never
modifies the underlying program)
* s/Method/Function/g in other random places as well
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
40 files changed, 331 insertions, 372 deletions
diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index d689d93..9f908c6 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -95,11 +95,3 @@ void FindUnsafePointerTypes::printResults(const Module *M, CW << " #" << Counter << ". " << (Value*)*I << "\n"; } } - -// getAnalysisUsageInfo - Of course, we provide ourself... -// -void FindUnsafePointerTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Provided.push_back(FindUnsafePointerTypes::ID); -} diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 5c961d2..86061d8 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -93,11 +93,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); -} diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index 197bed2..bb0f582 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -52,19 +52,19 @@ void IntervalPartition::updatePredecessors(cfg::Interval *Int) { // IntervalPartition ctor - Build the first level interval partition for the // specified function... // -bool IntervalPartition::runOnMethod(Function *M) { - assert(M->front() && "Cannot operate on prototypes!"); +bool IntervalPartition::runOnFunction(Function *F) { + assert(F->front() && "Cannot operate on prototypes!"); // Pass false to intervals_begin because we take ownership of it's memory - function_interval_iterator I = intervals_begin(M, false); - assert(I != intervals_end(M) && "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(M), + 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/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index e9e4245..0518aef 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -1,6 +1,6 @@ -//===-- MethodLiveVarInfo.cpp - Live Variable Analysis for a Function -----===// +//===-- FunctionLiveVarInfo.cpp - Live Variable Analysis for a Function ---===// // -// This is the interface to method level live variable information that is +// This is the interface to function level live variable information that is // provided by live variable analysis. // //===----------------------------------------------------------------------===// @@ -39,10 +39,10 @@ const ValueSet &MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const { //----------------------------------------------------------------------------- -// Performs live var analysis for a method +// Performs live var analysis for a function //----------------------------------------------------------------------------- -bool MethodLiveVarInfo::runOnMethod(Function *Meth) { +bool MethodLiveVarInfo::runOnFunction(Function *Meth) { M = Meth; if (DEBUG_LV) std::cerr << "Analysing live variables ...\n"; @@ -149,12 +149,12 @@ void MethodLiveVarInfo::releaseMemory() { //----------------------------------------------------------------------------- // Following functions will give the LiveVar info for any machine instr in -// a method. It should be called after a call to analyze(). +// a function. It should be called after a call to analyze(). // // Thsese functions calucluates live var info for all the machine instrs in a // BB when LVInfo for one inst is requested. Hence, this function is useful // when live var info is required for many (or all) instructions in a basic -// block. Also, the arguments to this method does not require specific +// block. Also, the arguments to this function does not require specific // iterators. //----------------------------------------------------------------------------- diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index ef47936..c34aef7 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -35,7 +35,7 @@ void cfg::LoopInfo::releaseMemory() { //===----------------------------------------------------------------------===// // cfg::LoopInfo implementation // -bool cfg::LoopInfo::runOnMethod(Function *F) { +bool cfg::LoopInfo::runOnFunction(Function *F) { releaseMemory(); Calculate(getAnalysis<DominatorSet>()); // Update return false; @@ -53,11 +53,10 @@ void cfg::LoopInfo::Calculate(const DominatorSet &DS) { TopLevelLoops[i]->setLoopDepth(1); } -void cfg::LoopInfo::getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(DominatorSet::ID); - Provided.push_back(ID); +void cfg::LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(DominatorSet::ID); + AU.addProvided(ID); } diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 71ee3d7..387b673 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -22,7 +22,7 @@ using std::set; AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>()); AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>()); -bool cfg::DominatorSet::runOnMethod(Function *F) { +bool cfg::DominatorSet::runOnFunction(Function *F) { Doms.clear(); // Reset from the last time we were run... if (isPostDominator()) @@ -129,17 +129,16 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { } while (Changed); } -// getAnalysisUsageInfo - This obviously provides a dominator set, but it also -// uses the UnifyMethodExitNodes pass if building post-dominators +// getAnalysisUsage - This obviously provides a dominator set, but it also +// uses the UnifyFunctionExitNodes pass if building post-dominators // -void cfg::DominatorSet::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { +void cfg::DominatorSet::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); if (isPostDominator()) { - Provided.push_back(PostDomID); - Requires.push_back(UnifyMethodExitNodes::ID); + AU.addProvided(PostDomID); + AU.addRequired(UnifyMethodExitNodes::ID); } else { - Provided.push_back(ID); + AU.addProvided(ID); } } diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index f10bf3c..adc8903 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -1480,26 +1480,23 @@ instrIsFeasible(const SchedulingManager& S, //--------------------------------------------------------------------------- namespace { - class InstructionSchedulingWithSSA : public MethodPass { + class InstructionSchedulingWithSSA : public FunctionPass { const TargetMachine ⌖ public: inline InstructionSchedulingWithSSA(const TargetMachine &T) : target(T) {} - // getAnalysisUsageInfo - We use LiveVarInfo... - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(MethodLiveVarInfo::ID); - Destroyed.push_back(MethodLiveVarInfo::ID); + // getAnalysisUsage - We use LiveVarInfo... + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(MethodLiveVarInfo::ID); } - bool runOnMethod(Function *F); + bool runOnFunction(Function *F); }; } // end anonymous namespace bool -InstructionSchedulingWithSSA::runOnMethod(Function *M) +InstructionSchedulingWithSSA::runOnFunction(Function *M) { if (SchedDebugLevel == Sched_Disable) return false; @@ -1544,8 +1541,6 @@ InstructionSchedulingWithSSA::runOnMethod(Function *M) } -MethodPass* -createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) -{ +Pass *createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) { return new InstructionSchedulingWithSSA(tgt); } diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 0b680ab..c22ede9 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -40,14 +40,14 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags, // RegisterAllocation pass front end... //---------------------------------------------------------------------------- namespace { - class RegisterAllocator : public MethodPass { + class RegisterAllocator : public FunctionPass { TargetMachine &Target; public: inline RegisterAllocator(TargetMachine &T) : Target(T) {} - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { if (DEBUG_RA) - cerr << "\n******************** Method "<< F->getName() + cerr << "\n******************** Function "<< F->getName() << " ********************\n"; PhyRegAlloc PRA(F, Target, &getAnalysis<MethodLiveVarInfo>(), @@ -58,17 +58,14 @@ namespace { return false; } - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(cfg::LoopInfo::ID); - Requires.push_back(MethodLiveVarInfo::ID); - Destroyed.push_back(MethodLiveVarInfo::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::LoopInfo::ID); + AU.addRequired(MethodLiveVarInfo::ID); } }; } -MethodPass *getRegisterAllocator(TargetMachine &T) { +Pass *getRegisterAllocator(TargetMachine &T) { return new RegisterAllocator(T); } diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index f10bf3c..adc8903 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -1480,26 +1480,23 @@ instrIsFeasible(const SchedulingManager& S, //--------------------------------------------------------------------------- namespace { - class InstructionSchedulingWithSSA : public MethodPass { + class InstructionSchedulingWithSSA : public FunctionPass { const TargetMachine ⌖ public: inline InstructionSchedulingWithSSA(const TargetMachine &T) : target(T) {} - // getAnalysisUsageInfo - We use LiveVarInfo... - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(MethodLiveVarInfo::ID); - Destroyed.push_back(MethodLiveVarInfo::ID); + // getAnalysisUsage - We use LiveVarInfo... + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(MethodLiveVarInfo::ID); } - bool runOnMethod(Function *F); + bool runOnFunction(Function *F); }; } // end anonymous namespace bool -InstructionSchedulingWithSSA::runOnMethod(Function *M) +InstructionSchedulingWithSSA::runOnFunction(Function *M) { if (SchedDebugLevel == Sched_Disable) return false; @@ -1544,8 +1541,6 @@ InstructionSchedulingWithSSA::runOnMethod(Function *M) } -MethodPass* -createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) -{ +Pass *createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) { return new InstructionSchedulingWithSSA(tgt); } diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index e9e4245..0518aef 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -1,6 +1,6 @@ -//===-- MethodLiveVarInfo.cpp - Live Variable Analysis for a Function -----===// +//===-- FunctionLiveVarInfo.cpp - Live Variable Analysis for a Function ---===// // -// This is the interface to method level live variable information that is +// This is the interface to function level live variable information that is // provided by live variable analysis. // //===----------------------------------------------------------------------===// @@ -39,10 +39,10 @@ const ValueSet &MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const { //----------------------------------------------------------------------------- -// Performs live var analysis for a method +// Performs live var analysis for a function //----------------------------------------------------------------------------- -bool MethodLiveVarInfo::runOnMethod(Function *Meth) { +bool MethodLiveVarInfo::runOnFunction(Function *Meth) { M = Meth; if (DEBUG_LV) std::cerr << "Analysing live variables ...\n"; @@ -149,12 +149,12 @@ void MethodLiveVarInfo::releaseMemory() { //----------------------------------------------------------------------------- // Following functions will give the LiveVar info for any machine instr in -// a method. It should be called after a call to analyze(). +// a function. It should be called after a call to analyze(). // // Thsese functions calucluates live var info for all the machine instrs in a // BB when LVInfo for one inst is requested. Hence, this function is useful // when live var info is required for many (or all) instructions in a basic -// block. Also, the arguments to this method does not require specific +// block. Also, the arguments to this function does not require specific // iterators. //----------------------------------------------------------------------------- diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 0b680ab..c22ede9 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -40,14 +40,14 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags, // RegisterAllocation pass front end... //---------------------------------------------------------------------------- namespace { - class RegisterAllocator : public MethodPass { + class RegisterAllocator : public FunctionPass { TargetMachine &Target; public: inline RegisterAllocator(TargetMachine &T) : Target(T) {} - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { if (DEBUG_RA) - cerr << "\n******************** Method "<< F->getName() + cerr << "\n******************** Function "<< F->getName() << " ********************\n"; PhyRegAlloc PRA(F, Target, &getAnalysis<MethodLiveVarInfo>(), @@ -58,17 +58,14 @@ namespace { return false; } - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(cfg::LoopInfo::ID); - Requires.push_back(MethodLiveVarInfo::ID); - Destroyed.push_back(MethodLiveVarInfo::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::LoopInfo::ID); + AU.addRequired(MethodLiveVarInfo::ID); } }; } -MethodPass *getRegisterAllocator(TargetMachine &T) { +Pass *getRegisterAllocator(TargetMachine &T) { return new RegisterAllocator(T); } diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index a46f2ef..83e5487 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -4,10 +4,10 @@ // LLVM. The code in this file assumes that the specified module has already // been compiled into the internal data structures of the Module. // -// This code largely consists of two LLVM Pass's: a MethodPass and a Pass. The -// MethodPass is pipelined together with all of the rest of the code generation -// stages, and the Pass runs at the end to emit code for global variables and -// such. +// This code largely consists of two LLVM Pass's: a FunctionPass and a Pass. +// The FunctionPass is pipelined together with all of the rest of the code +// generation stages, and the Pass runs at the end to emit code for global +// variables and such. // //===----------------------------------------------------------------------===// @@ -197,7 +197,7 @@ public: // SparcFunctionAsmPrinter Code //===----------------------------------------------------------------------===// -struct SparcFunctionAsmPrinter : public MethodPass, public AsmPrinter { +struct SparcFunctionAsmPrinter : public FunctionPass, public AsmPrinter { inline SparcFunctionAsmPrinter(std::ostream &os, const TargetMachine &t) : AsmPrinter(os, t) {} @@ -206,7 +206,7 @@ struct SparcFunctionAsmPrinter : public MethodPass, public AsmPrinter { return false; } - virtual bool runOnMethod(Function *F) { + virtual bool runOnFunction(Function *F) { startFunction(F); emitFunction(F); endFunction(F); @@ -410,7 +410,7 @@ SparcFunctionAsmPrinter::emitFunction(const Function *M) } // End anonymous namespace -Pass *UltraSparc::getMethodAsmPrinterPass(PassManager &PM, std::ostream &Out) { +Pass *UltraSparc::getFunctionAsmPrinterPass(PassManager &PM, std::ostream &Out){ return new SparcFunctionAsmPrinter(Out, *this); } diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 12c86b8..0e80179 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -128,7 +128,7 @@ public: // returned in `minstrVec'. Any temporary registers (TmpInstruction) // created are returned in `tempVec'. // - virtual void CreateCodeToLoadConst(Function* method, + virtual void CreateCodeToLoadConst(Function *F, Value* val, Instruction* dest, std::vector<MachineInstr*>& minstrVec, @@ -141,7 +141,7 @@ public: // The generated instructions are returned in `minstrVec'. // Any temp. registers (TmpInstruction) created are returned in `tempVec'. // - virtual void CreateCodeToCopyIntToFloat(Function* method, + virtual void CreateCodeToCopyIntToFloat(Function* F, Value* val, Instruction* dest, std::vector<MachineInstr*>& minstr, @@ -152,7 +152,7 @@ public: // `val' to an integer value `dest' by copying to memory and back. // See the previous function for information about return values. // - virtual void CreateCodeToCopyFloatToInt(Function* method, + virtual void CreateCodeToCopyFloatToInt(Function* F, Value* val, Instruction* dest, std::vector<MachineInstr*>& minstr, @@ -161,7 +161,7 @@ public: // create copy instruction(s) virtual void CreateCopyInstructionsByType(const TargetMachine& target, - Function* method, + Function* F, Value* src, Instruction* dest, std::vector<MachineInstr*>& minstr) const; @@ -224,7 +224,7 @@ class UltraSparcRegInfo : public MachineRegInfo { // ======================== Private Methods ============================= // The following methods are used to color special live ranges (e.g. - // method args and return values etc.) with specific hardware registers + // function args and return values etc.) with specific hardware registers // as required. See SparcRegInfo.cpp for the implementation. // void setCallOrRetArgCol(LiveRange *LR, unsigned RegNo, @@ -251,7 +251,7 @@ class UltraSparcRegInfo : public MachineRegInfo { unsigned getCallInstNumArgs(const MachineInstr *CallMI) const; - // The following 3 methods are used to find the RegType (see enum above) + // The following 3 methods are used to find the RegType (see enum above) // of a LiveRange, Value and using the unified RegClassID int getRegType(const LiveRange *LR) const; int getRegType(const Value *Val) const; @@ -272,7 +272,7 @@ class UltraSparcRegInfo : public MachineRegInfo { // The following 2 methods are used to order the instructions addeed by - // the register allocator in association with method calling. See + // the register allocator in association with function calling. See // SparcRegInfo.cpp for more details // void moveInst2OrdVec(std::vector<MachineInstr *> &OrdVec, @@ -344,7 +344,7 @@ public: virtual int getZeroRegNum() const; // getCallAddressReg - returns the reg used for pushing the address when a - // method is called. This can be used for other purposes between calls + // function is called. This can be used for other purposes between calls // unsigned getCallAddressReg() const; @@ -357,7 +357,7 @@ public: // The following methods are used to color special live ranges (e.g. - // method args and return values etc.) with specific hardware registers + // function args and return values etc.) with specific hardware registers // as required. See SparcRegInfo.cpp for the implementation for Sparc. // void suggestRegs4MethodArgs(const Function *Meth, @@ -499,16 +499,16 @@ public: UltraSparcFrameInfo(const TargetMachine &tgt) : MachineFrameInfo(tgt) {} public: - int getStackFrameSizeAlignment () const { return StackFrameSizeAlignment;} - int getMinStackFrameSize () const { return MinStackFrameSize; } - int getNumFixedOutgoingArgs () const { return NumFixedOutgoingArgs; } - int getSizeOfEachArgOnStack () const { return SizeOfEachArgOnStack; } - bool argsOnStackHaveFixedSize () const { return true; } + int getStackFrameSizeAlignment() const { return StackFrameSizeAlignment;} + int getMinStackFrameSize() const { return MinStackFrameSize; } + int getNumFixedOutgoingArgs() const { return NumFixedOutgoingArgs; } + int getSizeOfEachArgOnStack() const { return SizeOfEachArgOnStack; } + bool argsOnStackHaveFixedSize() const { return true; } // // These methods compute offsets using the frame contents for a - // particular method. The frame contents are obtained from the - // MachineCodeInfoForMethod object for the given method. + // particular function. The frame contents are obtained from the + // MachineCodeInfoForMethod object for the given function. // int getFirstIncomingArgOffset (MachineCodeForMethod& mcInfo, bool& growUp) const @@ -623,7 +623,7 @@ public: virtual void addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); private: - Pass *getMethodAsmPrinterPass(PassManager &PM, std::ostream &Out); + Pass *getFunctionAsmPrinterPass(PassManager &PM, std::ostream &Out); Pass *getModuleAsmPrinterPass(PassManager &PM, std::ostream &Out); Pass *getEmitBytecodeToAsmPass(std::ostream &Out); }; diff --git a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp index 2dad572..17cd73b 100644 --- a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp +++ b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp @@ -21,11 +21,11 @@ namespace { -class InsertPrologEpilogCode : public MethodPass { +class InsertPrologEpilogCode : public FunctionPass { TargetMachine &Target; public: InsertPrologEpilogCode(TargetMachine &T) : Target(T) {} - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(F); if (!mcodeInfo.isCompiledAsLeafMethod()) { InsertPrologCode(F); diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index de778e2..306b85a 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -126,21 +126,21 @@ UltraSparc::UltraSparc() // Native code generation for a specified target. //===---------------------------------------------------------------------===// -class ConstructMachineCodeForFunction : public MethodPass { +class ConstructMachineCodeForFunction : public FunctionPass { TargetMachine &Target; public: inline ConstructMachineCodeForFunction(TargetMachine &T) : Target(T) {} - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { MachineCodeForMethod::construct(F, Target); return false; } }; -class InstructionSelection : public MethodPass { +class InstructionSelection : public FunctionPass { TargetMachine &Target; public: inline InstructionSelection(TargetMachine &T) : Target(T) {} - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { if (SelectInstructionsForMethod(F, Target)) { cerr << "Instr selection failed for function " << F->getName() << "\n"; abort(); @@ -149,12 +149,12 @@ public: } }; -struct FreeMachineCodeForFunction : public MethodPass { +struct FreeMachineCodeForFunction : public FunctionPass { static void freeMachineCode(Instruction *I) { MachineCodeForInstruction::destroy(I); } - bool runOnMethod(Function *F) { + 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) @@ -197,7 +197,7 @@ void UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { // allowing machine code representations for functions to be free'd after the // function has been emitted. // - PM.add(getMethodAsmPrinterPass(PM, Out)); + PM.add(getFunctionAsmPrinterPass(PM, Out)); PM.add(new FreeMachineCodeForFunction()); // Free stuff no longer needed // Emit Module level assembly after all of the functions have been processed. diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index 26cf5ca..f6e6109 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -74,8 +74,8 @@ static bool doHoistPHIConstants(Function *M) { } namespace { - struct HoistPHIConstants : public MethodPass { - virtual bool runOnMethod(Function *F) { return doHoistPHIConstants(F); } + struct HoistPHIConstants : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doHoistPHIConstants(F); } }; } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index ef51105..ee28b13 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -58,8 +58,8 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, } namespace { - // FIXME: ConstantMerge should not be a methodPass!!! - class ConstantMerge : public MethodPass { + // FIXME: ConstantMerge should not be a FunctionPass!!! + class ConstantMerge : public FunctionPass { protected: std::map<Constant*, GlobalVariable*> Constants; unsigned LastConstantSeen; @@ -73,7 +73,7 @@ namespace { return ::mergeDuplicateConstants(M, LastConstantSeen, Constants); } - bool runOnMethod(Function *) { return false; } + bool runOnFunction(Function *) { return false; } // doFinalization - Clean up internal state for this module // @@ -85,10 +85,10 @@ namespace { }; struct DynamicConstantMerge : public ConstantMerge { - // runOnMethod - Check to see if any globals have been added to the + // runOnFunction - Check to see if any globals have been added to the // global list for the module. If so, eliminate them. // - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { return ::mergeDuplicateConstants(F->getParent(), LastConstantSeen, Constants); } diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index 4f2e24d..3ba6057 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -35,7 +35,7 @@ using std::cerr; static const Type *PtrSByte = 0; // 'sbyte*' type namespace { - struct CleanupGCCOutput : public MethodPass { + struct CleanupGCCOutput : public FunctionPass { // doPassInitialization - For this pass, it removes global symbol table // entries for primitive types. These are never used for linking in GCC and // they make the output uglier to look at, so we nuke them. @@ -46,18 +46,15 @@ namespace { // runOnFunction - This method simplifies the specified function hopefully. // - bool runOnMethod(Function *F); + bool runOnFunction(Function *F); // doPassFinalization - Strip out type names that are unused by the program bool doFinalization(Module *M); - // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job... + // getAnalysisUsage - This function needs FindUsedTypes to do its job... // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - // FIXME: Invalidates the CFG - Required.push_back(FindUsedTypes::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(FindUsedTypes::ID); } }; } @@ -246,7 +243,7 @@ static inline void RefactorPredecessor(BasicBlock *BB, BasicBlock *Pred) { } -// runOnMethod - Loop through the function and fix problems with the PHI nodes +// runOnFunction - Loop through the function and fix problems with the PHI nodes // in the current function. The problem is that PHI nodes might exist with // multiple entries for the same predecessor. GCC sometimes generates code that // looks like this: @@ -262,7 +259,7 @@ static inline void RefactorPredecessor(BasicBlock *BB, BasicBlock *Pred) { // bb8: %reg119 = phi uint [ 0, %bbX ], [ 1, %bb7 ] // // -bool CleanupGCCOutput::runOnMethod(Function *M) { +bool CleanupGCCOutput::runOnFunction(Function *M) { bool Changed = false; // Don't use iterators because invalidation gets messy... for (unsigned MI = 0; MI < M->size(); ++MI) { diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index ae9bd39..cd9c35f 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -1,6 +1,7 @@ //===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===// // // This transform is designed to eliminate unreachable internal globals +// FIXME: GlobalDCE should update the callgraph, not destroy it! // //===----------------------------------------------------------------------===// @@ -55,16 +56,12 @@ namespace { return RemoveUnreachableFunctions(M, getAnalysis<CallGraph>()); } - // getAnalysisUsageInfo - This function works on the call graph of a module. + // getAnalysisUsage - This function works on the call graph of a module. // It is capable of updating the call graph to reflect the new state of the // module. // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(CallGraph::ID); - // FIXME: This should update the callgraph, not destroy it! - Destroyed.push_back(CallGraph::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(CallGraph::ID); } }; } diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 7f96278..fcb1e4f 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -53,7 +53,7 @@ static inline void RemapInstruction(Instruction *I, } } -// InlineMethod - This function forcibly inlines the called function into the +// InlineFunction - This function forcibly inlines the called function into the // basic block of the caller. This returns false if it is not possible to // inline this call. The program is still in a well defined state if this // occurs though. @@ -63,8 +63,8 @@ static inline void RemapInstruction(Instruction *I, // exists in the instruction stream. Similiarly this will inline a recursive // function by one level. // -bool InlineMethod(BasicBlock::iterator CIIt) { - assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!"); +bool InlineFunction(BasicBlock::iterator CIIt) { + assert(isa<CallInst>(*CIIt) && "InlineFunction only works on CallInst nodes"); assert((*CIIt)->getParent() && "Instruction not embedded in basic block!"); assert((*CIIt)->getParent()->getParent() && "Instruction not in function!"); @@ -209,7 +209,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) { return true; } -bool InlineMethod(CallInst *CI) { +bool InlineFunction(CallInst *CI) { assert(CI->getParent() && "CallInst not embeded in BasicBlock!"); BasicBlock *PBB = CI->getParent(); @@ -217,12 +217,12 @@ bool InlineMethod(CallInst *CI) { assert(CallIt != PBB->end() && "CallInst has parent that doesn't contain CallInst?!?"); - return InlineMethod(CallIt); + return InlineFunction(CallIt); } static inline bool ShouldInlineFunction(const CallInst *CI, const Function *F) { assert(CI->getParent() && CI->getParent()->getParent() && - "Call not embedded into a method!"); + "Call not embedded into a function!"); // Don't inline a recursive call. if (CI->getParent()->getParent() == F) return false; @@ -244,7 +244,7 @@ static inline bool DoFunctionInlining(BasicBlock *BB) { // Check to see if we should inline this function Function *F = CI->getCalledFunction(); if (F && ShouldInlineFunction(CI, F)) - return InlineMethod(I); + return InlineFunction(I); } } return false; @@ -270,11 +270,11 @@ static bool doFunctionInlining(Function *F) { } namespace { - struct FunctionInlining : public MethodPass { - virtual bool runOnMethod(Function *F) { + struct FunctionInlining : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doFunctionInlining(F); } }; } -Pass *createMethodInliningPass() { return new FunctionInlining(); } +Pass *createFunctionInliningPass() { return new FunctionInlining(); } diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index b5dd937..2a6d184 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -28,12 +28,6 @@ using std::map; using std::vector; -//FIXME: These headers are only included because the analyses are killed!!! -#include "llvm/Analysis/CallGraph.h" -#include "llvm/Analysis/FindUsedTypes.h" -#include "llvm/Analysis/FindUnsafePointerTypes.h" -//FIXME end - // To enable debugging, uncomment this... //#define DEBUG_MST(x) x @@ -273,7 +267,7 @@ void MutateStructTypes::processGlobals(Module *M) { if (Meth->hasName()) Meth->setName("OLD."+Meth->getName()); - // Insert the new function into the method list... to be filled in later.. + // Insert the new function into the function list... to be filled in later M->getFunctionList().push_back(NewMeth); // Keep track of the association... @@ -325,10 +319,10 @@ void MutateStructTypes::removeDeadGlobals(Module *M) { -// transformMethod - This transforms the instructions of the function to use the -// new types. +// transformFunction - This transforms the instructions of the function to use +// the new types. // -void MutateStructTypes::transformMethod(Function *m) { +void MutateStructTypes::transformFunction(Function *m) { const Function *M = m; map<const GlobalValue*, GlobalValue*>::iterator GMI = GlobalMap.find(M); if (GMI == GlobalMap.end()) @@ -518,19 +512,9 @@ bool MutateStructTypes::run(Module *M) { processGlobals(M); for_each(M->begin(), M->end(), - bind_obj(this, &MutateStructTypes::transformMethod)); + bind_obj(this, &MutateStructTypes::transformFunction)); removeDeadGlobals(M); return true; } -// getAnalysisUsageInfo - This function needs the results of the -// FindUsedTypes and FindUnsafePointerTypes analysis passes... -// -void MutateStructTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Destroyed.push_back(FindUsedTypes::ID); - Destroyed.push_back(FindUnsafePointerTypes::ID); - Destroyed.push_back(CallGraph::ID); -} diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index 43683e4..bd67fe1 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -234,12 +234,11 @@ namespace { bool run(Module *M); - // getAnalysisUsageInfo - This function requires data structure information + // getAnalysisUsage - This function requires data structure information // to be able to see what is pool allocatable. // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &,Pass::AnalysisSet &) { - Required.push_back(DataStructure::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(DataStructure::ID); } public: diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 5c64aa3..33e0289 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -1,4 +1,4 @@ -//===- SimpleStructMutation.cpp - Swap structure elements around ---*- C++ -*--=// +//===- SimpleStructMutation.cpp - Swap structure elements around -*- C++ -*--=// // // This pass does a simple transformation that swaps all of the elements of the // struct types in the program around. @@ -31,15 +31,13 @@ namespace { return Changed; } - // getAnalysisUsageInfo - This function needs the results of the + // getAnalysisUsage - This function needs the results of the // FindUsedTypes and FindUnsafePointerTypes analysis passes... // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(FindUsedTypes::ID); - Required.push_back(FindUnsafePointerTypes::ID); - MutateStructTypes::getAnalysisUsageInfo(Required, Destroyed, Provided); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(FindUsedTypes::ID); + AU.addRequired(FindUnsafePointerTypes::ID); + MutateStructTypes::getAnalysisUsage(AU); } private: diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index aa2cfdd..860119e 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -37,17 +37,15 @@ using std::vector; -class ProfilePaths: public MethodPass { +class ProfilePaths: public FunctionPass { public: - bool runOnMethod(Function *M); + bool runOnFunction(Function *F); // Before this pass, make sure that there is only one // entry and only one exit node for the function in the CFG of the function // - void ProfilePaths::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(UnifyMethodExitNodes::ID); + void ProfilePaths::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(UnifyMethodExitNodes::ID); } }; @@ -68,7 +66,7 @@ static Node *findBB(std::set<Node *> &st, BasicBlock *BB){ } //Per function pass for inserting counters and trigger code -bool ProfilePaths::runOnMethod(Function *M){ +bool ProfilePaths::runOnFunction(Function *M){ //Transform the cfg s.t. we have just one exit node BasicBlock *ExitNode = getAnalysis<UnifyMethodExitNodes>().getExitNode(); diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 12fc84b..d05d33d 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -23,7 +23,7 @@ using std::vector; using std::string; namespace { - class InsertTraceCode : public MethodPass { + class InsertTraceCode : public FunctionPass { bool TraceBasicBlockExits, TraceFunctionExits; Function *PrintfFunc; public: @@ -46,14 +46,14 @@ namespace { // runOnFunction - This method does the work. // - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { return doit(F, TraceBasicBlockExits, TraceFunctionExits, PrintfFunc); } }; } // end anonymous namespace -Pass *createTraceValuesPassForMethod() { // Just trace functions +Pass *createTraceValuesPassForFunction() { // Just trace functions return new InsertTraceCode(false, true); } diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index 51d863d..f556ced 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -440,7 +440,7 @@ static bool DoRaisePass(Function *F) { } -// RaisePointerReferences::doit - Raise a method representation to a higher +// RaisePointerReferences::doit - Raise a function representation to a higher // level. // static bool doRPR(Function *F) { @@ -458,7 +458,7 @@ static bool doRPR(Function *F) { cerr << "Looping: \n" << F; #endif - // Iterate over the method, refining it, until it converges on a stable + // Iterate over the function, refining it, until it converges on a stable // state LocalChange = false; while (DoRaisePass(F)) LocalChange = true; @@ -470,8 +470,8 @@ static bool doRPR(Function *F) { } namespace { - struct RaisePointerReferences : public MethodPass { - virtual bool runOnMethod(Function *F) { return doRPR(F); } + struct RaisePointerReferences : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doRPR(F); } }; } diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index c129b5c..71069c6 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -29,7 +29,7 @@ using std::cerr; // It's public interface consists of a constructor and a doADCE() method. // class ADCE { - Function *M; // The method that we are working on... + Function *M; // The function that we are working on std::vector<Instruction*> WorkList; // Instructions that just became live std::set<Instruction*> LiveSet; // The set of live instructions bool MadeChanges; @@ -38,11 +38,11 @@ class ADCE { // The public interface for this class // public: - // ADCE Ctor - Save the method to operate on... - inline ADCE(Function *m) : M(m), MadeChanges(false) {} + // ADCE Ctor - Save the function to operate on... + inline ADCE(Function *f) : M(f), MadeChanges(false) {} // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning - // true if the method was modified. + // true if the function was modified. bool doADCE(cfg::DominanceFrontier &CDG); //===--------------------------------------------------------------------===// @@ -75,14 +75,14 @@ private: // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning -// true if the method was modified. +// true if the function was modified. // bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { #ifdef DEBUG_ADCE cerr << "Function: " << M; #endif - // Iterate over all of the instructions in the method, eliminating trivially + // Iterate over all of the instructions in the function, eliminating trivially // dead instructions, and marking instructions live that are known to be // needed. Perform the walk in depth first order so that we avoid marking any // instructions live in basic blocks that are unreachable. These blocks will @@ -173,7 +173,7 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { if (EntryBlock && EntryBlock != M->front()) { if (isa<PHINode>(EntryBlock->front())) { // Cannot make the first block be a block with a PHI node in it! Instead, - // strip the first basic block of the method to contain no instructions, + // strip the first basic block of the function to contain no instructions, // then add a simple branch to the "real" entry node... // BasicBlock *E = M->front(); @@ -191,9 +191,9 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { } else { - // We need to move the new entry block to be the first bb of the method. + // We need to move the new entry block to be the first bb of the function Function::iterator EBI = find(M->begin(), M->end(), EntryBlock); - std::swap(*EBI, *M->begin());// Exchange old location with start of method + std::swap(*EBI, *M->begin()); // Exchange old location with start of fn MadeChanges = true; } } @@ -289,19 +289,17 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks, } namespace { - struct AgressiveDCE : public MethodPass { + struct AgressiveDCE : public FunctionPass { // doADCE - Execute the Agressive Dead Code Elimination Algorithm // - virtual bool runOnMethod(Function *M) { - return ADCE(M).doADCE( + virtual bool runOnFunction(Function *F) { + return ADCE(F).doADCE( getAnalysis<cfg::DominanceFrontier>(cfg::DominanceFrontier::PostDomID)); } - // getAnalysisUsageInfo - We require post dominance frontiers (aka Control + // getAnalysisUsage - We require post dominance frontiers (aka Control // Dependence Graph) - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(cfg::DominanceFrontier::PostDomID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::DominanceFrontier::PostDomID); } }; } diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 26d5c7d..a8cd02f 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -211,8 +211,8 @@ static bool DoConstPropPass(Function *F) { } namespace { - struct ConstantPropogation : public MethodPass { - inline bool runOnMethod(Function *F) { + struct ConstantPropogation : public FunctionPass { + inline bool runOnFunction(Function *F) { bool Modified = false; // Fold constants until we make no progress... diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 6169730..0d6f293 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -9,7 +9,7 @@ // predecessor only has one successor. // * Eliminates PHI nodes for basic blocks with a single predecessor // * Eliminates a basic block that only contains an unconditional branch -// * Eliminates method prototypes that are not referenced +// * Eliminates function prototypes that are not referenced // // TODO: This should REALLY be worklist driven instead of iterative. Right now, // we scan linearly through values, removing unused ones as we go. The problem @@ -163,13 +163,13 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { // iterator that designates the first element remaining after the block that // was deleted. // -// WARNING: The entry node of a method may not be simplified. +// WARNING: The entry node of a function may not be simplified. // bool SimplifyCFG(Function::iterator &BBIt) { BasicBlock *BB = *BBIt; Function *M = BB->getParent(); - assert(BB && BB->getParent() && "Block not embedded in method!"); + assert(BB && BB->getParent() && "Block not embedded in function!"); assert(BB->getTerminator() && "Degenerate basic block encountered!"); assert(BB->getParent()->front() != BB && "Can't Simplify entry block!"); @@ -258,7 +258,7 @@ bool SimplifyCFG(Function::iterator &BBIt) { Pred->getInstList().push_back(Def); // Add to end... } - // Remove basic block from the method... and advance iterator to the + // Remove basic block from the function... and advance iterator to the // next valid block... BB = M->getBasicBlocks().remove(BBIt); @@ -303,7 +303,7 @@ static bool DoDCEPass(Function *F) { } // Remove unused global values - This removes unused global values of no -// possible value. This currently includes unused method prototypes and +// possible value. This currently includes unused function prototypes and // unitialized global variables. // static bool RemoveUnusedGlobalValues(Module *Mod) { @@ -313,7 +313,7 @@ static bool RemoveUnusedGlobalValues(Module *Mod) { Function *Meth = *MI; if (Meth->isExternal() && Meth->use_size() == 0) { // No references to prototype? - //cerr << "Removing method proto: " << Meth->getName() << endl; + //cerr << "Removing function proto: " << Meth->getName() << endl; delete Mod->getFunctionList().remove(MI); // Remove prototype // Remove moves iterator to point to the next one automatically Changed = true; @@ -339,7 +339,7 @@ static bool RemoveUnusedGlobalValues(Module *Mod) { } namespace { - struct DeadCodeElimination : public MethodPass { + struct DeadCodeElimination : public FunctionPass { // Pass Interface... virtual bool doInitialization(Module *M) { @@ -349,7 +349,7 @@ namespace { // It is possible that we may require multiple passes over the code to fully // eliminate dead code. Iterate until we are done. // - virtual bool runOnMethod(Function *F) { + virtual bool runOnFunction(Function *F) { bool Changed = false; while (DoDCEPass(F)) Changed = true; return Changed; diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index 390cd95..0ec72c6 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -1,4 +1,4 @@ -//===- llvm/Transforms/DecomposeMultiDimRefs.cpp - Lower array refs to 1D -----=// +//===- llvm/Transforms/DecomposeMultiDimRefs.cpp - Lower array refs to 1D ---=// // // DecomposeMultiDimRefs - // Convert multi-dimensional references consisting of any combination @@ -7,7 +7,7 @@ // has at most one index (except structure references, // which need an extra leading index of [0]). // -//===---------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/DecomposeMultiDimRefs.h" #include "llvm/ConstantVals.h" @@ -171,9 +171,13 @@ doDecomposeMultiDimRefs(Function *F) namespace { - struct DecomposeMultiDimRefsPass : public MethodPass { - virtual bool runOnMethod(Function *F) { return doDecomposeMultiDimRefs(F); } + struct DecomposeMultiDimRefsPass : public FunctionPass { + virtual bool runOnFunction(Function *F) { + return doDecomposeMultiDimRefs(F); + } }; } -Pass *createDecomposeMultiDimRefsPass() { return new DecomposeMultiDimRefsPass(); } +Pass *createDecomposeMultiDimRefsPass() { + return new DecomposeMultiDimRefsPass(); +} diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index a388025..40ee5c7 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -188,7 +188,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { } static bool doit(Function *M, cfg::LoopInfo &Loops) { - // Induction Variables live in the header nodes of the loops of the method... + // Induction Variables live in the header nodes of the loops of the function return reduce_apply_bool(Loops.getTopLevelLoops().begin(), Loops.getTopLevelLoops().end(), std::bind1st(std::ptr_fun(TransformLoop), &Loops)); @@ -196,15 +196,13 @@ static bool doit(Function *M, cfg::LoopInfo &Loops) { namespace { - struct InductionVariableSimplify : public MethodPass { - virtual bool runOnMethod(Function *F) { + struct InductionVariableSimplify : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doit(F, getAnalysis<cfg::LoopInfo>()); } - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(cfg::LoopInfo::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::LoopInfo::ID); } }; } diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 9931a6b..8e559a3 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -183,7 +183,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { Function *M = Header->getParent(); if (M->hasSymbolTable()) { - // Only name the induction variable if the method isn't stripped. + // Only name the induction variable if the function isn't stripped. PHIName = "ind_var"; AddName = "ind_var_next"; } @@ -353,7 +353,7 @@ static bool ProcessInterval(cfg::Interval *Int) { // static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) { // This currently just prints out information about the interval structure - // of the method... + // of the function... #if 0 static unsigned N = 0; cerr << "\n***********Interval Partition #" << (++N) << "************\n\n"; @@ -398,17 +398,14 @@ bool InductionVariableCannonicalize::doIt(Function *M, } -bool InductionVariableCannonicalize::runOnMethod(Function *F) { +bool InductionVariableCannonicalize::runOnFunction(Function *F) { return doIt(F, getAnalysis<cfg::IntervalPartition>()); } -// getAnalysisUsageInfo - This function works on the call graph of a module. +// getAnalysisUsage - This function works on the call graph of a module. // It is capable of updating the call graph to reflect the new state of the // module. // -void InductionVariableCannonicalize::getAnalysisUsageInfo( - Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(cfg::IntervalPartition::ID); +void InductionVariableCannonicalize::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::IntervalPartition::ID); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index c2fa84c..dea0244 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -27,7 +27,7 @@ namespace { - class InstCombiner : public MethodPass, + class InstCombiner : public FunctionPass, public InstVisitor<InstCombiner, Instruction*> { // Worklist of all of the instructions that need to be simplified. std::vector<Instruction*> WorkList; @@ -44,7 +44,7 @@ namespace { public: - virtual bool runOnMethod(Function *F); + virtual bool runOnFunction(Function *F); // Visitation implementation - Implement instruction combining for different // instruction types. The semantics are as follows: @@ -205,7 +205,7 @@ Instruction *InstCombiner::visitMemAccessInst(MemAccessInst *MAI) { } -bool InstCombiner::runOnMethod(Function *F) { +bool InstCombiner::runOnFunction(Function *F) { bool Changed = false; WorkList.insert(WorkList.end(), inst_begin(F), inst_end(F)); diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 51a827d..e723fc8 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -34,9 +34,7 @@ using std::cerr; // InstVal class - This class represents the different lattice values that an -// instruction may occupy. It is a simple class with value semantics. The -// potential constant value that is pointed to is owned by the constant pool -// for the method being optimized. +// instruction may occupy. It is a simple class with value semantics. // class InstVal { enum { @@ -83,7 +81,7 @@ public: // SCCP Class // // This class does all of the work of Sparse Conditional Constant Propogation. -// It's public interface consists of a constructor and a doSCCP() method. +// It's public interface consists of a constructor and a doSCCP() function. // class SCCP : public InstVisitor<SCCP> { Function *M; // The function that we are working on @@ -99,11 +97,11 @@ class SCCP : public InstVisitor<SCCP> { // public: - // SCCP Ctor - Save the method to operate on... + // SCCP Ctor - Save the function to operate on... inline SCCP(Function *f) : M(f) {} // doSCCP() - Run the Sparse Conditional Constant Propogation algorithm, and - // return true if the method was modified. + // return true if the function was modified. bool doSCCP(); //===--------------------------------------------------------------------===// @@ -212,10 +210,10 @@ private: // doSCCP() - Run the Sparse Conditional Constant Propogation algorithm, and -// return true if the method was modified. +// return true if the function was modified. // bool SCCP::doSCCP() { - // Mark the first block of the method as being executable... + // Mark the first block of the function as being executable... markExecutable(M->front()); // Process the work lists until their are empty! @@ -264,7 +262,7 @@ bool SCCP::doSCCP() { #endif - // Iterate over all of the instructions in a method, replacing them with + // Iterate over all of the instructions in a function, replacing them with // constants if we have found them to be of constant values. // bool MadeChanges = false; @@ -467,8 +465,8 @@ namespace { // SCCPPass - Use Sparse Conditional Constant Propogation // to prove whether a value is constant and whether blocks are used. // - struct SCCPPass : public MethodPass { - inline bool runOnMethod(Function *F) { + struct SCCPPass : public FunctionPass { + inline bool runOnFunction(Function *F) { SCCP S(F); return S.doSCCP(); } diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index a026fd6..36b465e 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -60,8 +60,8 @@ static bool doStripGlobalSymbols(Module *M) { } namespace { - struct SymbolStripping : public MethodPass { - virtual bool runOnMethod(Function *F) { + struct SymbolStripping : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doSymbolStripping(F); } }; diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 6f220f8..8726ed4 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -309,22 +309,20 @@ bool PromoteInstance::queuePhiNode(BasicBlock *bb, int i /*the alloca*/) namespace { - struct PromotePass : public MethodPass { + struct PromotePass : public FunctionPass { - // runOnMethod - To run this pass, first we calculate the alloca + // runOnFunction - To run this pass, first we calculate the alloca // instructions that are safe for promotion, then we promote each one. // - virtual bool runOnMethod(Function *F) { + virtual bool runOnFunction(Function *F) { return (bool)PromoteInstance(F, getAnalysis<DominanceFrontier>()); } - // getAnalysisUsageInfo - We need dominance frontiers + // getAnalysisUsage - We need dominance frontiers // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(DominanceFrontier::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(DominanceFrontier::ID); } }; } diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 71ee3d7..387b673 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -22,7 +22,7 @@ using std::set; AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>()); AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>()); -bool cfg::DominatorSet::runOnMethod(Function *F) { +bool cfg::DominatorSet::runOnFunction(Function *F) { Doms.clear(); // Reset from the last time we were run... if (isPostDominator()) @@ -129,17 +129,16 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { } while (Changed); } -// getAnalysisUsageInfo - This obviously provides a dominator set, but it also -// uses the UnifyMethodExitNodes pass if building post-dominators +// getAnalysisUsage - This obviously provides a dominator set, but it also +// uses the UnifyFunctionExitNodes pass if building post-dominators // -void cfg::DominatorSet::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { +void cfg::DominatorSet::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); if (isPostDominator()) { - Provided.push_back(PostDomID); - Requires.push_back(UnifyMethodExitNodes::ID); + AU.addProvided(PostDomID); + AU.addRequired(UnifyMethodExitNodes::ID); } else { - Provided.push_back(ID); + AU.addProvided(ID); } } diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 9596f52..14ebd50 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -71,10 +71,10 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, } void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg, - Pass *P, const Pass::AnalysisSet &Set) { + Pass *P, const std::vector<AnalysisID> &Set){ if (PassDebugging >= PassDetails && !Set.empty()) { std::cerr << (void*)P << std::string(Depth*2+3, ' ') << Msg << " Analyses:"; - for (unsigned i = 0; i < Set.size(); ++i) { + for (unsigned i = 0; i != Set.size(); ++i) { Pass *P = Set[i].createPass(); // Good thing this is just debug code... std::cerr << " " << typeid(*P).name(); delete P; @@ -93,57 +93,54 @@ void Pass::dumpPassStructure(unsigned Offset = 0) { // Pass Implementation // -void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Required, - AnalysisSet &Destroyed, AnalysisSet &Provided) { - PM->addPass(this, Required, Destroyed, Provided); +void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU) { + PM->addPass(this, AU); } //===----------------------------------------------------------------------===// -// MethodPass Implementation +// FunctionPass Implementation // -// run - On a module, we run this pass by initializing, ronOnMethod'ing once -// for every method in the module, then by finalizing. +// run - On a module, we run this pass by initializing, runOnFunction'ing once +// for every function in the module, then by finalizing. // -bool MethodPass::run(Module *M) { +bool FunctionPass::run(Module *M) { bool Changed = doInitialization(M); for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!(*I)->isExternal()) // Passes are not run on external methods! - Changed |= runOnMethod(*I); + if (!(*I)->isExternal()) // Passes are not run on external functions! + Changed |= runOnFunction(*I); return Changed | doFinalization(M); } -// run - On a method, we simply initialize, run the method, then finalize. +// run - On a function, we simply initialize, run the function, then finalize. // -bool MethodPass::run(Function *F) { - if (F->isExternal()) return false; // Passes are not run on external methods! +bool FunctionPass::run(Function *F) { + if (F->isExternal()) return false;// Passes are not run on external functions! - return doInitialization(F->getParent()) | runOnMethod(F) + return doInitialization(F->getParent()) | runOnFunction(F) | doFinalization(F->getParent()); } -void MethodPass::addToPassManager(PassManagerT<Module> *PM, - AnalysisSet &Required, AnalysisSet &Destroyed, - AnalysisSet &Provided) { - PM->addPass(this, Required, Destroyed, Provided); +void FunctionPass::addToPassManager(PassManagerT<Module> *PM, + AnalysisUsage &AU) { + PM->addPass(this, AU); } -void MethodPass::addToPassManager(PassManagerT<Function> *PM, - AnalysisSet &Required, AnalysisSet &Destroyed, - AnalysisSet &Provided) { - PM->addPass(this, Required, Destroyed, Provided); +void FunctionPass::addToPassManager(PassManagerT<Function> *PM, + AnalysisUsage &AU) { + PM->addPass(this, AU); } //===----------------------------------------------------------------------===// // BasicBlockPass Implementation // -// To run this pass on a method, we simply call runOnBasicBlock once for each -// method. +// To run this pass on a function, we simply call runOnBasicBlock once for each +// function. // -bool BasicBlockPass::runOnMethod(Function *F) { +bool BasicBlockPass::runOnFunction(Function *F) { bool Changed = false; for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) Changed |= runOnBasicBlock(*I); @@ -159,16 +156,12 @@ bool BasicBlockPass::run(BasicBlock *BB) { } void BasicBlockPass::addToPassManager(PassManagerT<Function> *PM, - AnalysisSet &Required, - AnalysisSet &Destroyed, - AnalysisSet &Provided) { - PM->addPass(this, Required, Destroyed, Provided); + AnalysisUsage &AU) { + PM->addPass(this, AU); } void BasicBlockPass::addToPassManager(PassManagerT<BasicBlock> *PM, - AnalysisSet &Required, - AnalysisSet &Destroyed, - AnalysisSet &Provided) { - PM->addPass(this, Required, Destroyed, Provided); + AnalysisUsage &AU) { + PM->addPass(this, AU); } diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 4c521f1..a8c8d57 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -14,6 +14,7 @@ #include "llvm/Pass.h" #include <string> +#include <algorithm> //===----------------------------------------------------------------------===// // PMDebug class - a set of debugging functions, that are not to be @@ -26,7 +27,7 @@ struct PMDebug { static void PrintPassStructure(Pass *P); static void PrintPassInformation(unsigned,const char*,Pass *, Value *); static void PrintAnalysisSetInfo(unsigned,const char*,Pass *P, - const Pass::AnalysisSet&); + const std::vector<AnalysisID> &); }; @@ -107,15 +108,16 @@ public: PMDebug::PrintPassInformation(getDepth(), "Executing Pass", P, (Value*)M); // Get information about what analyses the pass uses... - std::vector<AnalysisID> Required, Destroyed, Provided; - P->getAnalysisUsageInfo(Required, Destroyed, Provided); - - PMDebug::PrintAnalysisSetInfo(getDepth(), "Required", P, Required); + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + PMDebug::PrintAnalysisSetInfo(getDepth(), "Required", P, + AnUsage.getRequiredSet()); #ifndef NDEBUG // All Required analyses should be available to the pass as it runs! - for (Pass::AnalysisSet::iterator I = Required.begin(), - E = Required.end(); I != E; ++I) { + for (vector<AnalysisID>::const_iterator + I = AnUsage.getRequiredSet().begin(), + E = AnUsage.getRequiredSet().end(); I != E; ++I) { assert(getAnalysisOrNullUp(*I) && "Analysis used but not available!"); } #endif @@ -127,17 +129,35 @@ public: if (Changed) PMDebug::PrintPassInformation(getDepth()+1, "Made Modification", P, (Value*)M); - PMDebug::PrintAnalysisSetInfo(getDepth(), "Destroyed", P, Destroyed); - PMDebug::PrintAnalysisSetInfo(getDepth(), "Provided", P, Provided); + PMDebug::PrintAnalysisSetInfo(getDepth(), "Preserved", P, + AnUsage.getPreservedSet()); + PMDebug::PrintAnalysisSetInfo(getDepth(), "Provided", P, + AnUsage.getProvidedSet()); + + + // Erase all analyses not in the preserved set... + if (!AnUsage.preservesAll()) { + const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet(); + for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin(), + E = CurrentAnalyses.end(); I != E; ) + if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) != + PreservedSet.end()) + ++I; // This analysis is preserved, leave it in the available set... + else { +#if MAP_DOESNT_HAVE_BROKEN_ERASE_MEMBER + I = CurrentAnalyses.erase(I); // Analysis not preserved! +#else + // GCC 2.95.3 STL doesn't have correct erase member! + CurrentAnalyses.erase(I); + I = CurrentAnalyses.begin(); +#endif + } + } - // Erase all analyses in the destroyed set... - for (Pass::AnalysisSet::iterator I = Destroyed.begin(), - E = Destroyed.end(); I != E; ++I) - CurrentAnalyses.erase(*I); - // Add all analyses in the provided set... - for (Pass::AnalysisSet::iterator I = Provided.begin(), - E = Provided.end(); I != E; ++I) + for (std::vector<AnalysisID>::const_iterator + I = AnUsage.getProvidedSet().begin(), + E = AnUsage.getProvidedSet().end(); I != E; ++I) CurrentAnalyses[*I] = P; // Free memory for any passes that we are the last use of... @@ -226,12 +246,13 @@ public: // void add(PassClass *P) { // Get information about what analyses the pass uses... - std::vector<AnalysisID> Required, Destroyed, Provided; - P->getAnalysisUsageInfo(Required, Destroyed, Provided); + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + const std::vector<AnalysisID> &Required = AnUsage.getRequiredSet(); // Loop over all of the analyses used by this pass, - for (std::vector<AnalysisID>::iterator I = Required.begin(), - E = Required.end(); I != E; ++I) { + for (std::vector<AnalysisID>::const_iterator I = Required.begin(), + E = Required.end(); I != E; ++I) { if (getAnalysisOrNullDown(*I) == 0) add((PassClass*)I->createPass()); } @@ -240,7 +261,7 @@ public: // depends on the class of the pass, and is critical to laying out passes in // an optimal order.. // - P->addToPassManager(this, Required, Destroyed, Provided); + P->addToPassManager(this, AnUsage); } private: @@ -253,15 +274,17 @@ private: // // For generic Pass subclasses (which are interprocedural passes), we simply // add the pass to the end of the pass list and terminate any accumulation of - // MethodPasses that are present. + // FunctionPass's that are present. // - void addPass(PassClass *P, Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, Pass::AnalysisSet &Provided) { + void addPass(PassClass *P, AnalysisUsage &AnUsage) { + const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet(); + const std::vector<AnalysisID> &ProvidedSet = AnUsage.getProvidedSet(); + // Providers are analysis classes which are forbidden to modify the module // they are operating on, so they are allowed to be reordered to before the // batcher... // - if (Batcher && Provided.empty()) + if (Batcher && ProvidedSet.empty()) closeBatcher(); // This pass cannot be batched! // Set the Resolver instance variable in the Pass so that it knows where to @@ -274,34 +297,46 @@ private: // being used by this pass. This is used to make sure that analyses are not // free'd before we have to use them... // - for (std::vector<AnalysisID>::iterator I = Required.begin(), - E = Required.end(); I != E; ++I) + for (std::vector<AnalysisID>::const_iterator I = RequiredSet.begin(), + E = RequiredSet.end(); I != E; ++I) markPassUsed(*I, P); // Mark *I as used by P - // Erase all analyses in the destroyed set... - for (std::vector<AnalysisID>::iterator I = Destroyed.begin(), - E = Destroyed.end(); I != E; ++I) - CurrentAnalyses.erase(*I); + // Erase all analyses not in the preserved set... + if (!AnUsage.preservesAll()) { + const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet(); + for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin(), + E = CurrentAnalyses.end(); I != E; ) + if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) != + PreservedSet.end()) + ++I; // This analysis is preserved, leave it in the available set... + else { +#if MAP_DOESNT_HAVE_BROKEN_ERASE_MEMBER + I = CurrentAnalyses.erase(I); // Analysis not preserved! +#else + CurrentAnalyses.erase(I);// GCC 2.95.3 STL doesn't have correct erase! + I = CurrentAnalyses.begin(); +#endif + } + } // Add all analyses in the provided set... - for (std::vector<AnalysisID>::iterator I = Provided.begin(), - E = Provided.end(); I != E; ++I) + for (std::vector<AnalysisID>::const_iterator I = ProvidedSet.begin(), + E = ProvidedSet.end(); I != E; ++I) CurrentAnalyses[*I] = P; // For now assume that our results are never used... LastUseOf[P] = P; } - // For MethodPass subclasses, we must be sure to batch the MethodPasses - // together in a MethodPassBatcher object so that all of the analyses are run - // together a method at a time. + // For FunctionPass subclasses, we must be sure to batch the FunctionPass's + // together in a BatcherClass object so that all of the analyses are run + // together a function at a time. // - void addPass(SubPassClass *MP, Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, Pass::AnalysisSet &Provided) { + void addPass(SubPassClass *MP, AnalysisUsage &AnUsage) { if (Batcher == 0) // If we don't have a batcher yet, make one now. Batcher = new BatcherClass(this); // The Batcher will queue them passes up - MP->addToPassManager(Batcher, Required, Destroyed, Provided); + MP->addToPassManager(Batcher, AnUsage); } // closeBatcher - Terminate the batcher that is being worked on. @@ -364,12 +399,12 @@ template<> struct PassManagerTraits<BasicBlock> : public BasicBlockPass { //===----------------------------------------------------------------------===// // PassManagerTraits<Function> Specialization // -// This pass manager is used to group together all of the MethodPass's +// This pass manager is used to group together all of the FunctionPass's // into a single unit. // -template<> struct PassManagerTraits<Function> : public MethodPass { +template<> struct PassManagerTraits<Function> : public FunctionPass { // PassClass - The type of passes tracked by this PassManager - typedef MethodPass PassClass; + typedef FunctionPass PassClass; // SubPassClass - The types of classes that should be collated together typedef BasicBlockPass SubPassClass; @@ -384,17 +419,17 @@ template<> struct PassManagerTraits<Function> : public MethodPass { typedef PassManagerT<Function> PMType; // runPass - Specify how the pass should be run on the UnitType - static bool runPass(PassClass *P, Function *M) { - return P->runOnMethod(M); + static bool runPass(PassClass *P, Function *F) { + return P->runOnFunction(F); } // getPMName() - Return the name of the unit the PassManager operates on for // debugging. const char *getPMName() const { return "Function"; } - // Implement the MethodPass interface... + // Implement the FunctionPass interface... virtual bool doInitialization(Module *M); - virtual bool runOnMethod(Function *M); + virtual bool runOnFunction(Function *F); virtual bool doFinalization(Module *M); }; @@ -410,7 +445,7 @@ template<> struct PassManagerTraits<Module> : public Pass { typedef Pass PassClass; // SubPassClass - The types of classes that should be collated together - typedef MethodPass SubPassClass; + typedef FunctionPass SubPassClass; // BatcherClass - The type to use for collation of subtypes... typedef PassManagerT<Function> BatcherClass; @@ -467,8 +502,8 @@ inline bool PassManagerTraits<Function>::doInitialization(Module *M) { return Changed; } -inline bool PassManagerTraits<Function>::runOnMethod(Function *M) { - return ((PMType*)this)->runOnUnit(M); +inline bool PassManagerTraits<Function>::runOnFunction(Function *F) { + return ((PMType*)this)->runOnUnit(F); } inline bool PassManagerTraits<Function>::doFinalization(Module *M) { diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 5c7f98b..691f118 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -53,7 +53,7 @@ namespace { // Anonymous namespace for class - struct Verifier : public MethodPass, InstVisitor<Verifier> { + struct Verifier : public FunctionPass, InstVisitor<Verifier> { bool Broken; Verifier() : Broken(false) {} @@ -63,7 +63,7 @@ namespace { // Anonymous namespace for class return false; } - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { visit(F); return false; } |