From b12914bfc0f76a7a48357162d5f4c39a1343e69b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 20 Sep 2004 04:48:05 +0000 Subject: 'Pass' should now not be derived from by clients. Instead, they should derive from ModulePass. Instead of implementing Pass::run, then should implement ModulePass::runOnModule. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16436 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CallGraph.h | 6 ++-- .../llvm/Analysis/DataStructure/DataStructure.h | 14 ++++----- include/llvm/Analysis/FindUnsafePointerTypes.h | 4 +-- include/llvm/Analysis/FindUsedTypes.h | 4 +-- include/llvm/Assembly/PrintModulePass.h | 4 +-- include/llvm/Bytecode/WriteBytecodePass.h | 4 +-- include/llvm/CallGraphSCCPass.h | 4 +-- include/llvm/Pass.h | 36 +++++++++++++++------- include/llvm/PassManager.h | 1 + lib/Analysis/AliasAnalysisCounter.cpp | 4 +-- lib/Analysis/DataStructure/BottomUpClosure.cpp | 2 +- lib/Analysis/DataStructure/CompleteBottomUp.cpp | 2 +- lib/Analysis/DataStructure/DataStructureAA.cpp | 4 +-- lib/Analysis/DataStructure/DataStructureOpt.cpp | 4 +-- lib/Analysis/DataStructure/IPModRef.cpp | 2 +- lib/Analysis/DataStructure/IPModRef.h | 4 +-- lib/Analysis/DataStructure/Local.cpp | 2 +- lib/Analysis/DataStructure/MemoryDepAnalysis.cpp | 2 +- lib/Analysis/DataStructure/MemoryDepAnalysis.h | 4 +-- lib/Analysis/DataStructure/Parallelize.cpp | 6 ++-- lib/Analysis/DataStructure/PgmDependenceGraph.h | 4 +-- lib/Analysis/DataStructure/Steensgaard.cpp | 6 ++-- lib/Analysis/DataStructure/TopDownClosure.cpp | 2 +- lib/Analysis/IPA/Andersens.cpp | 4 +-- lib/Analysis/IPA/CallGraph.cpp | 2 +- lib/Analysis/IPA/CallGraphSCCPass.cpp | 2 +- lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 2 +- lib/Analysis/IPA/FindUsedTypes.cpp | 2 +- lib/Analysis/IPA/GlobalsModRef.cpp | 4 +-- lib/Analysis/ProfileInfoLoaderPass.cpp | 6 ++-- lib/Target/CBackend/CBackend.cpp | 6 ++-- lib/Target/CBackend/Writer.cpp | 6 ++-- lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 12 +++----- lib/Target/SparcV9/InternalGlobalMapper.cpp | 14 ++++----- lib/Target/SparcV9/MappingInfo.cpp | 4 +-- lib/Target/SparcV9/MappingInfo.h | 6 ++-- lib/Target/SparcV9/SparcV9Internals.h | 6 ++-- lib/Target/SparcV9/SparcV9StackSlots.cpp | 2 +- lib/Transforms/IPO/ArgumentPromotion.cpp | 2 +- lib/Transforms/IPO/ConstantMerge.cpp | 8 ++--- lib/Transforms/IPO/DeadArgumentElimination.cpp | 10 +++--- lib/Transforms/IPO/DeadTypeElimination.cpp | 8 ++--- lib/Transforms/IPO/ExtractFunction.cpp | 6 ++-- lib/Transforms/IPO/FunctionResolution.cpp | 8 ++--- lib/Transforms/IPO/GlobalDCE.cpp | 8 ++--- lib/Transforms/IPO/GlobalOpt.cpp | 8 ++--- lib/Transforms/IPO/IPConstantPropagation.cpp | 8 ++--- lib/Transforms/IPO/InlineSimple.cpp | 2 +- lib/Transforms/IPO/Internalize.cpp | 6 ++-- lib/Transforms/IPO/LoopExtractor.cpp | 10 +++--- lib/Transforms/IPO/LowerSetJmp.cpp | 16 ++++------ lib/Transforms/IPO/PruneEH.cpp | 2 +- lib/Transforms/IPO/RaiseAllocations.cpp | 8 ++--- lib/Transforms/Instrumentation/BlockProfiling.cpp | 12 ++++---- lib/Transforms/Instrumentation/EdgeProfiling.cpp | 6 ++-- lib/Transforms/Instrumentation/EmitFunctions.cpp | 6 ++-- .../Instrumentation/TraceBasicBlocks.cpp | 6 ++-- lib/VMCore/PassManagerT.h | 10 +++--- tools/analyze/AnalysisWrappers.cpp | 4 +-- tools/analyze/GraphPrinters.cpp | 4 +-- tools/analyze/analyze.cpp | 4 +-- tools/bugpoint/ExtractFunction.cpp | 6 ++-- tools/opt/AnalysisWrappers.cpp | 4 +-- tools/opt/GraphPrinters.cpp | 4 +-- 64 files changed, 193 insertions(+), 186 deletions(-) diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 8f2c302389..446ea500d4 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -64,7 +64,7 @@ class CallGraphNode; //===----------------------------------------------------------------------===// // CallGraph class definition // -class CallGraph : public Pass { +class CallGraph : public ModulePass { Module *Mod; // The module this call graph represents typedef std::map FunctionMapTy; @@ -150,8 +150,8 @@ public: CallGraph() : Root(0), CallsExternalNode(0) {} ~CallGraph() { destroy(); } - // run - Compute the call graph for the specified module. - virtual bool run(Module &M); + // runOnModule - Compute the call graph for the specified module. + virtual bool runOnModule(Module &M); // getAnalysisUsage - This obviously provides a call graph virtual void getAnalysisUsage(AnalysisUsage &AU) const { diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index 9351ed4c98..34575a2db8 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -40,14 +40,14 @@ namespace DataStructureAnalysis { // FIXME: This should be a Function pass that can be USED by a Pass, and would // be automatically preserved. Until we can do that, this is a Pass. // -class LocalDataStructures : public Pass { +class LocalDataStructures : public ModulePass { // DSInfo, one graph for each function hash_map DSInfo; DSGraph *GlobalsGraph; public: ~LocalDataStructures() { releaseMemory(); } - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); bool hasGraph(const Function &F) const { return DSInfo.find(const_cast(&F)) != DSInfo.end(); @@ -86,7 +86,7 @@ public: /// data structure graphs for all of the functions in the program. This pass /// only performs a "Bottom Up" propagation (hence the name). /// -class BUDataStructures : public Pass { +class BUDataStructures : public ModulePass { protected: // DSInfo, one graph for each function hash_map DSInfo; @@ -95,7 +95,7 @@ protected: public: ~BUDataStructures() { releaseMemory(); } - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); bool hasGraph(const Function &F) const { return DSInfo.find(const_cast(&F)) != DSInfo.end(); @@ -149,7 +149,7 @@ private: /// for each function using the closed graphs for the callers computed /// by the bottom-up pass. /// -class TDDataStructures : public Pass { +class TDDataStructures : public ModulePass { // DSInfo, one graph for each function hash_map DSInfo; hash_set ArgsRemainIncomplete; @@ -157,7 +157,7 @@ class TDDataStructures : public Pass { public: ~TDDataStructures() { releaseMyMemory(); } - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); bool hasGraph(const Function &F) const { return DSInfo.find(const_cast(&F)) != DSInfo.end(); @@ -207,7 +207,7 @@ private: /// allocation. /// struct CompleteBUDataStructures : public BUDataStructures { - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); bool hasGraph(const Function &F) const { return DSInfo.find(const_cast(&F)) != DSInfo.end(); diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h index a2306021f9..2d453f087a 100644 --- a/include/llvm/Analysis/FindUnsafePointerTypes.h +++ b/include/llvm/Analysis/FindUnsafePointerTypes.h @@ -31,7 +31,7 @@ namespace llvm { class PointerType; -struct FindUnsafePointerTypes : public Pass { +struct FindUnsafePointerTypes : public ModulePass { // UnsafeTypes - Set of types that are not safe to transform. std::set UnsafeTypes; public: @@ -44,7 +44,7 @@ public: /// values of various types. If they are deemed to be 'unsafe' note that the /// type is not safe to transform. /// - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); /// print - Loop over the results of the analysis, printing out unsafe types. /// diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index 69471791ab..143d6ce031 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -21,7 +21,7 @@ namespace llvm { class Type; -class FindUsedTypes : public Pass { +class FindUsedTypes : public ModulePass { std::set UsedTypes; public: /// getTypes - After the pass has been run, return the set containing all of @@ -47,7 +47,7 @@ private: public: /// run - This incorporates all types used by the specified module - bool run(Module &M); + bool runOnModule(Module &M); /// getAnalysisUsage - We do not modify anything. virtual void getAnalysisUsage(AnalysisUsage &AU) const { diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index fc7e6f48a5..102701fde2 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -24,7 +24,7 @@ namespace llvm { -class PrintModulePass : public Pass { +class PrintModulePass : public ModulePass { std::ostream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: @@ -37,7 +37,7 @@ public: if (DeleteStream) delete Out; } - bool run(Module &M) { + bool runOnModule(Module &M) { (*Out) << M << std::flush; return false; } diff --git a/include/llvm/Bytecode/WriteBytecodePass.h b/include/llvm/Bytecode/WriteBytecodePass.h index b8863e6b47..5b6325d521 100644 --- a/include/llvm/Bytecode/WriteBytecodePass.h +++ b/include/llvm/Bytecode/WriteBytecodePass.h @@ -21,7 +21,7 @@ namespace llvm { -class WriteBytecodePass : public Pass { +class WriteBytecodePass : public ModulePass { std::ostream *Out; // ostream to print on bool DeleteStream; public: @@ -34,7 +34,7 @@ public: if (DeleteStream) delete Out; } - bool run(Module &M) { + bool runOnModule(Module &M) { WriteBytecodeToFile(&M, *Out); return false; } diff --git a/include/llvm/CallGraphSCCPass.h b/include/llvm/CallGraphSCCPass.h index b7fba387ea..389a80c9e3 100644 --- a/include/llvm/CallGraphSCCPass.h +++ b/include/llvm/CallGraphSCCPass.h @@ -28,7 +28,7 @@ namespace llvm { class CallGraphNode; class CallGraph; -struct CallGraphSCCPass : public Pass { +struct CallGraphSCCPass : public ModulePass { /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. @@ -52,7 +52,7 @@ struct CallGraphSCCPass : public Pass { /// run - Run this pass, returning true if a modification was made to the /// module argument. This is implemented in terms of the runOnSCC method. /// - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); /// getAnalysisUsage - For this class, we declare that we require and preserve diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 08496c5d2e..77f630c316 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -84,10 +84,10 @@ public: /// const PassInfo *getPassInfo() const; - /// run - Run this pass, returning true if a modification was made to the + /// runPass - Run this pass, returning true if a modification was made to the /// module argument. This should be implemented by all concrete subclasses. /// - virtual bool run(Module &M) = 0; + virtual bool runPass(Module &M) = 0; /// print - Print out the internal state of the pass. This is called by /// Analyze to print out the contents of an analysis. Otherwise it is not @@ -200,13 +200,27 @@ private: friend class PassManagerT; friend class PassManagerT; friend class PassManagerT; - virtual void addToPassManager(PassManagerT *PM, AnalysisUsage &AU); }; inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { P.print(OS, 0); return OS; } +//===----------------------------------------------------------------------===// +/// ModulePass class - This class is used to implement unstructured +/// interprocedural optimizations and analyses. ModulePass's may do anything +/// they want to the program. +/// +struct ModulePass : public Pass { + + /// runOnModule - Virtual method overriden by subclasses to process the module + /// being operated on. + virtual bool runOnModule(Module &M) = 0; + + bool runPass(Module &M) { return runOnModule(M); } + + virtual void addToPassManager(PassManagerT *PM, AnalysisUsage &AU); +}; //===----------------------------------------------------------------------===// @@ -214,7 +228,7 @@ inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { /// not need to be run. This is useful for things like target information and /// "basic" versions of AnalysisGroups. /// -struct ImmutablePass : public Pass { +struct ImmutablePass : public ModulePass { /// initializePass - This method may be overriden by immutable passes to allow /// them to perform various initialization actions they require. This is /// primarily because an ImmutablePass can "require" another ImmutablePass, @@ -225,14 +239,13 @@ struct ImmutablePass : public Pass { /// ImmutablePasses are never run. /// - virtual bool run(Module &M) { return false; } + virtual bool runOnModule(Module &M) { return false; } private: friend class PassManagerT; virtual void addToPassManager(PassManagerT *PM, AnalysisUsage &AU); }; - //===----------------------------------------------------------------------===// /// FunctionPass class - This class is used to implement most global /// optimizations. Optimizations should subclass this class if they meet the @@ -242,7 +255,7 @@ private: /// 2. Optimizing a function does not cause the addition or removal of any /// functions in the module /// -struct FunctionPass : public Pass { +struct FunctionPass : public ModulePass { /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -258,10 +271,11 @@ struct FunctionPass : public Pass { /// virtual bool doFinalization(Module &M) { return false; } - /// run - On a module, we run this pass by initializing, ronOnFunction'ing - /// once for every function in the module, then by finalizing. + /// runOnModule - On a module, we run this pass by initializing, + /// ronOnFunction'ing once for every function in the module, then by + /// finalizing. /// - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); /// run - On a function, we simply initialize, run the function, then /// finalize. @@ -323,7 +337,7 @@ struct BasicBlockPass : public FunctionPass { /// To run directly on the basic block, we initialize, runOnBasicBlock, then /// finalize. /// - bool run(BasicBlock &BB); + bool runPass(BasicBlock &BB); private: friend class PassManagerT; diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index b1d369b925..1b77c875d9 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -20,6 +20,7 @@ namespace llvm { class Pass; +class ModulePass; class Module; class ModuleProvider; template class PassManagerT; diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 09fd6b9e0e..b17941fdec 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -18,7 +18,7 @@ using namespace llvm; namespace { - class AliasAnalysisCounter : public Pass, public AliasAnalysis { + class AliasAnalysisCounter : public ModulePass, public AliasAnalysis { unsigned No, May, Must; unsigned NoMR, JustRef, JustMod, MR; const char *Name; @@ -64,7 +64,7 @@ namespace { } } - bool run(Module &M) { + bool runOnModule(Module &M) { InitializeAliasAnalysis(this); Name = dynamic_cast(&getAnalysis())->getPassName(); return false; diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 4bc6fafcf6..bf4b01cfc1 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -35,7 +35,7 @@ using namespace DS; // run - Calculate the bottom up data structure graphs for each function in the // program. // -bool BUDataStructures::run(Module &M) { +bool BUDataStructures::runOnModule(Module &M) { LocalDataStructures &LocalDSA = getAnalysis(); GlobalsGraph = new DSGraph(LocalDSA.getGlobalsGraph()); GlobalsGraph->setPrintAuxCalls(); diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index b2a0f4ba9b..ee111e9d8f 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -32,7 +32,7 @@ namespace { // run - Calculate the bottom up data structure graphs for each function in the // program. // -bool CompleteBUDataStructures::run(Module &M) { +bool CompleteBUDataStructures::runOnModule(Module &M) { BUDataStructures &BU = getAnalysis(); GlobalsGraph = new DSGraph(BU.getGlobalsGraph()); GlobalsGraph->setPrintAuxCalls(); diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp index 3cff79526f..6444cc8aeb 100644 --- a/lib/Analysis/DataStructure/DataStructureAA.cpp +++ b/lib/Analysis/DataStructure/DataStructureAA.cpp @@ -19,7 +19,7 @@ using namespace llvm; namespace { - class DSAA : public Pass, public AliasAnalysis { + class DSAA : public ModulePass, public AliasAnalysis { TDDataStructures *TD; BUDataStructures *BU; public: @@ -32,7 +32,7 @@ namespace { // run - Build up the result graph, representing the pointer graph for the // program. // - bool run(Module &M) { + bool runOnModule(Module &M) { InitializeAliasAnalysis(this); TD = &getAnalysis(); BU = &getAnalysis(); diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index f7a1ed9af3..1996aea67d 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -25,10 +25,10 @@ namespace { Statistic<> NumGlobalsIsolated("ds-opt", "Number of globals with references dropped"); - class DSOpt : public Pass { + class DSOpt : public ModulePass { TDDataStructures *TD; public: - bool run(Module &M) { + bool runOnModule(Module &M) { TD = &getAnalysis(); bool Changed = OptimizeGlobals(M); return Changed; diff --git a/lib/Analysis/DataStructure/IPModRef.cpp b/lib/Analysis/DataStructure/IPModRef.cpp index ccc15f74e4..6793b0ecdb 100644 --- a/lib/Analysis/DataStructure/IPModRef.cpp +++ b/lib/Analysis/DataStructure/IPModRef.cpp @@ -374,7 +374,7 @@ void IPModRef::releaseMemory() // NO real interprocedural work because all that has been done the // data structure analysis. // -bool IPModRef::run(Module &theModule) +bool IPModRef::runOnModule(Module &theModule) { M = &theModule; diff --git a/lib/Analysis/DataStructure/IPModRef.h b/lib/Analysis/DataStructure/IPModRef.h index 4a825dbea3..f8ac15c1be 100644 --- a/lib/Analysis/DataStructure/IPModRef.h +++ b/lib/Analysis/DataStructure/IPModRef.h @@ -183,7 +183,7 @@ public: /// from an arbitrary callsite, or during an execution of a single call-site /// within the function. /// -class IPModRef : public Pass { +class IPModRef : public ModulePass { std::map funcToModRefInfoMap; Module* M; @@ -197,7 +197,7 @@ public: /// This initializes the module reference, and then computes IPModRef /// results immediately if demand-driven analysis was *not* specified. /// - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); /// getFunctionModRefInfo - Retrieve the Mod/Ref information for a single /// function diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index b21f2f1024..070d03738d 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -1023,7 +1023,7 @@ void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) { } -bool LocalDataStructures::run(Module &M) { +bool LocalDataStructures::runOnModule(Module &M) { GlobalsGraph = new DSGraph(getAnalysis()); const TargetData &TD = getAnalysis(); diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp index 49b6425930..f6c54fb5bb 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp @@ -457,7 +457,7 @@ bool MemoryDepAnalysis::runOnFunction(Function &F) { // Driver function to compute dependence graphs for every function. // This is temporary and will go away once this is a FunctionPass. // -bool MemoryDepAnalysis::run(Module& M) +bool MemoryDepAnalysis::runOnModule(Module& M) { for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) if (! FI->isExternal()) diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.h b/lib/Analysis/DataStructure/MemoryDepAnalysis.h index 570a03b679..ed21e5f687 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.h +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.h @@ -40,7 +40,7 @@ class FunctionModRefInfo; /// allowed to use a FunctionPass such as this one. ///--------------------------------------------------------------------------- -class MemoryDepAnalysis : public Pass { +class MemoryDepAnalysis : public ModulePass { /// The following map and depGraph pointer are temporary until this class /// becomes a FunctionPass instead of a module Pass. hash_map funcMap; @@ -63,7 +63,7 @@ public: /// Driver function to compute dependence graphs for every function. /// - bool run(Module &M); + bool runOnModule(Module &M); /// getGraph - Retrieve the dependence graph for a function. /// This is temporary and will go away once this is a FunctionPass. diff --git a/lib/Analysis/DataStructure/Parallelize.cpp b/lib/Analysis/DataStructure/Parallelize.cpp index 3dcb05ee06..2bb6c7ff46 100644 --- a/lib/Analysis/DataStructure/Parallelize.cpp +++ b/lib/Analysis/DataStructure/Parallelize.cpp @@ -388,11 +388,11 @@ void FindParallelCalls::visitCallInst(CallInst& CI) { //---------------------------------------------------------------------------- namespace { - class Parallelize: public Pass { + class Parallelize : public ModulePass { public: /// Driver functions to transform a program /// - bool run(Module& M); + bool runOnModule(Module& M); /// getAnalysisUsage - Modifies extensively so preserve nothing. /// Uses the DependenceGraph and the Top-down DS Graph (only to find @@ -409,7 +409,7 @@ namespace { } -bool Parallelize::run(Module& M) { +bool Parallelize::runOnModule(Module& M) { hash_set parallelFunctions; hash_set safeParallelFunctions; hash_set indirectlyCalled; diff --git a/lib/Analysis/DataStructure/PgmDependenceGraph.h b/lib/Analysis/DataStructure/PgmDependenceGraph.h index ec6f927a7e..d7774943bd 100644 --- a/lib/Analysis/DataStructure/PgmDependenceGraph.h +++ b/lib/Analysis/DataStructure/PgmDependenceGraph.h @@ -200,7 +200,7 @@ public: /// allowed to use a FunctionPass such as this one. ///--------------------------------------------------------------------------- -class PgmDependenceGraph: public Pass { +class PgmDependenceGraph: public ModulePass { /// Information about the function being analyzed. /// @@ -253,7 +253,7 @@ public: /// Driver function to compute dependence graphs for every function. /// - bool run(Module& M) { return true; } + bool runOnModule(Module& M) { return true; } /// getGraph() -- Retrieve the pgm dependence graph for a function. /// This is temporary and will go away once this is a FunctionPass. diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index deeb8b3450..b0718a18b9 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -22,7 +22,7 @@ using namespace llvm; namespace { - class Steens : public Pass, public AliasAnalysis { + class Steens : public ModulePass, public AliasAnalysis { DSGraph *ResultGraph; DSGraph *GlobalsGraph; // FIXME: Eliminate globals graph stuff from DNE public: @@ -39,7 +39,7 @@ namespace { // run - Build up the result graph, representing the pointer graph for the // program. // - bool run(Module &M); + bool runOnModule(Module &M); virtual void releaseMyMemory() { delete ResultGraph; ResultGraph = 0; } @@ -103,7 +103,7 @@ void Steens::ResolveFunctionCall(Function *F, const DSCallSite &Call, /// run - Build up the result graph, representing the pointer graph for the /// program. /// -bool Steens::run(Module &M) { +bool Steens::runOnModule(Module &M) { InitializeAliasAnalysis(this); assert(ResultGraph == 0 && "Result graph already allocated!"); LocalDataStructures &LDS = getAnalysis(); diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 1d861e8216..6271980737 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -51,7 +51,7 @@ void TDDataStructures::markReachableFunctionsExternallyAccessible(DSNode *N, // run - Calculate the top down data structure graphs for each function in the // program. // -bool TDDataStructures::run(Module &M) { +bool TDDataStructures::runOnModule(Module &M) { BUDataStructures &BU = getAnalysis(); GlobalsGraph = new DSGraph(BU.getGlobalsGraph()); GlobalsGraph->setPrintAuxCalls(); diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 7901c91abb..9ade25e1ee 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -75,7 +75,7 @@ namespace { Statistic<> NumIndirectCallees("anders-aa", "Number of indirect callees found"); - class Andersens : public Pass, public AliasAnalysis, + class Andersens : public ModulePass, public AliasAnalysis, private InstVisitor { /// Node class - This class is used to represent a memory object in the /// program, and is the primitive used to build the points-to graph. @@ -193,7 +193,7 @@ namespace { }; public: - bool run(Module &M) { + bool runOnModule(Module &M) { InitializeAliasAnalysis(this); IdentifyObjects(M); CollectConstraints(M); diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index dbf5b9f95b..a6d2836121 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -100,7 +100,7 @@ void CallGraph::addToCallGraph(Function *F) { } } -bool CallGraph::run(Module &M) { +bool CallGraph::runOnModule(Module &M) { destroy(); Mod = &M; diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index f7d7ab126a..8eb1c120b0 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -28,7 +28,7 @@ void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved(); } -bool CallGraphSCCPass::run(Module &M) { +bool CallGraphSCCPass::runOnModule(Module &M) { CallGraph &CG = getAnalysis(); bool Changed = doInitialization(CG); for (scc_iterator I = scc_begin(&CG), E = scc_end(&CG); diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 23ee99aa59..c0d0a62850 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -58,7 +58,7 @@ static inline bool isSafeInstruction(const Instruction &I) { } -bool FindUnsafePointerTypes::run(Module &Mod) { +bool FindUnsafePointerTypes::runOnModule(Module &Mod) { for (Module::iterator FI = Mod.begin(), E = Mod.end(); FI != E; ++FI) { const Function *F = FI; // We don't need/want write access diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 1f127fe82d..cb6b05ca4e 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -58,7 +58,7 @@ void FindUsedTypes::IncorporateValue(const Value *V) { // run - This incorporates all types used by the specified module // -bool FindUsedTypes::run(Module &m) { +bool FindUsedTypes::runOnModule(Module &m) { UsedTypes.clear(); // reset if run multiple times... // Loop over global variables, incorporating their types diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index c1f15ed238..2c4ad4aa4d 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -67,7 +67,7 @@ namespace { }; /// GlobalsModRef - The actual analysis pass. - class GlobalsModRef : public Pass, public AliasAnalysis { + class GlobalsModRef : public ModulePass, public AliasAnalysis { /// NonAddressTakenGlobals - The globals that do not have their addresses /// taken. std::set NonAddressTakenGlobals; @@ -77,7 +77,7 @@ namespace { std::map FunctionInfo; public: - bool run(Module &M) { + bool runOnModule(Module &M) { InitializeAliasAnalysis(this); // set up super class AnalyzeGlobals(M); // find non-addr taken globals AnalyzeCallGraph(getAnalysis(), M); // Propagate on CG diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp index cd3f575355..333e9e06f7 100644 --- a/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -28,7 +28,7 @@ namespace { cl::value_desc("filename"), cl::desc("Profile file loaded by -profile-loader")); - class LoaderPass : public Pass, public ProfileInfo { + class LoaderPass : public ModulePass, public ProfileInfo { std::string Filename; public: LoaderPass(const std::string &filename = "") @@ -45,7 +45,7 @@ namespace { } /// run - Load the profile information from the specified file. - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); }; RegisterOpt @@ -62,7 +62,7 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) { return new LoaderPass(Filename); } -bool LoaderPass::run(Module &M) { +bool LoaderPass::runOnModule(Module &M) { ProfileInfoLoader PIL("profile-loader", Filename, M); EdgeCounts.clear(); bool PrintedWarning = false; diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 45a771f9df..c26cfee54b 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -47,7 +47,7 @@ namespace { /// NameAllUsedStructs - This pass inserts names for any unnamed structure /// types that are used by the program. /// - class CBackendNameAllUsedStructs : public Pass { + class CBackendNameAllUsedStructs : public ModulePass { void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); } @@ -56,7 +56,7 @@ namespace { return "C backend type canonicalizer"; } - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); }; /// CWriter - This class is the main chunk of code that converts an LLVM @@ -216,7 +216,7 @@ namespace { /// the program, and removes names from structure types that are not used by the /// program. /// -bool CBackendNameAllUsedStructs::run(Module &M) { +bool CBackendNameAllUsedStructs::runOnModule(Module &M) { // Get a set of types that are used by the program... std::set UT = getAnalysis().getTypes(); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 45a771f9df..c26cfee54b 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -47,7 +47,7 @@ namespace { /// NameAllUsedStructs - This pass inserts names for any unnamed structure /// types that are used by the program. /// - class CBackendNameAllUsedStructs : public Pass { + class CBackendNameAllUsedStructs : public ModulePass { void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); } @@ -56,7 +56,7 @@ namespace { return "C backend type canonicalizer"; } - virtual bool run(Module &M); + virtual bool runOnModule(Module &M); }; /// CWriter - This class is the main chunk of code that converts an LLVM @@ -216,7 +216,7 @@ namespace { /// the program, and removes names from structure types that are not used by the /// program. /// -bool CBackendNameAllUsedStructs::run(Module &M) { +bool CBackendNameAllUsedStructs::runOnModule(Module &M) { // Get a set of types that are used by the program... std::set UT = getAnalysis().getTypes(); diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index 0826f76284..26332ca301 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -17,10 +17,7 @@ #include "llvm/Pass.h" #include "llvm/Bytecode/Writer.h" #include - -namespace llvm { - -using std::ostream; +using namespace llvm; namespace { @@ -87,14 +84,14 @@ namespace { } // SparcV9BytecodeWriter - Write bytecode out to a stream that is sparc'ified - class SparcV9BytecodeWriter : public Pass { + class SparcV9BytecodeWriter : public ModulePass { std::ostream &Out; public: SparcV9BytecodeWriter(std::ostream &out) : Out(out) {} const char *getPassName() const { return "Emit Bytecode to SparcV9 Assembly";} - virtual bool run(Module &M) { + virtual bool runOnModule(Module &M) { // Write an object containing the bytecode to the SPARC assembly stream writePrologue (Out, "LLVM BYTECODE OUTPUT", "LLVMBytecode"); osparcasmstream OS(Out); @@ -112,8 +109,7 @@ namespace { }; } // end anonymous namespace -Pass *createBytecodeAsmPrinterPass(std::ostream &Out) { +ModulePass *llvm::createBytecodeAsmPrinterPass(std::ostream &Out) { return new SparcV9BytecodeWriter(Out); } -} // End llvm namespace diff --git a/lib/Target/SparcV9/InternalGlobalMapper.cpp b/lib/Target/SparcV9/InternalGlobalMapper.cpp index 0cd2faa7c3..ef870b224f 100644 --- a/lib/Target/SparcV9/InternalGlobalMapper.cpp +++ b/lib/Target/SparcV9/InternalGlobalMapper.cpp @@ -27,13 +27,13 @@ namespace llvm { typedef std::vector GVVectorTy; -class InternalGlobalMapper : public Pass { +class InternalGlobalMapper : public ModulePass { public: - bool run (Module &M); + bool runOnModule(Module &M); }; -Pass *llvm::createInternalGlobalMapperPass () { - return new InternalGlobalMapper (); +ModulePass *llvm::createInternalGlobalMapperPass() { + return new InternalGlobalMapper(); } static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){ @@ -41,14 +41,14 @@ static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){ // be mangled), then put the GV, casted to sbyte*, in the vector. Otherwise // add a null. if (GV.hasInternalLinkage () && GV.hasName ()) - Vector.push_back (ConstantExpr::getCast - (&GV, PointerType::get (Type::SByteTy))); + Vector.push_back(ConstantExpr::getCast(&GV, + PointerType::get(Type::SByteTy))); else Vector.push_back (ConstantPointerNull::get (PointerType::get (Type::SByteTy))); } -bool InternalGlobalMapper::run (Module &M) { +bool InternalGlobalMapper::runOnModule(Module &M) { GVVectorTy gvvector; // Populate the vector with internal global values and their names. diff --git a/lib/Target/SparcV9/MappingInfo.cpp b/lib/Target/SparcV9/MappingInfo.cpp index 1a7212c9c0..58f19378aa 100644 --- a/lib/Target/SparcV9/MappingInfo.cpp +++ b/lib/Target/SparcV9/MappingInfo.cpp @@ -78,8 +78,8 @@ namespace { /// MappingInfoAsmPrinter Pass object, which uses OUT as its output /// stream for assembly output. /// -Pass *getMappingInfoAsmPrinterPass(std::ostream &out){ - return (new MappingInfoAsmPrinter(out)); +ModulePass *getMappingInfoAsmPrinterPass(std::ostream &out){ + return new MappingInfoAsmPrinter(out); } /// runOnFunction - Builds up the maps for the given function FI and then diff --git a/lib/Target/SparcV9/MappingInfo.h b/lib/Target/SparcV9/MappingInfo.h index 346a5f7cb9..1be2e865e8 100644 --- a/lib/Target/SparcV9/MappingInfo.h +++ b/lib/Target/SparcV9/MappingInfo.h @@ -21,10 +21,10 @@ namespace llvm { -class Pass; +class ModulePass; -Pass *getMappingInfoAsmPrinterPass(std::ostream &out); -Pass *createInternalGlobalMapperPass(); +ModulePass *getMappingInfoAsmPrinterPass(std::ostream &out); +ModulePass *createInternalGlobalMapperPass(); class MappingInfo { struct byteVector : public std::vector { diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 187d984a47..1f6599892c 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -28,7 +28,7 @@ namespace llvm { class LiveRange; class SparcV9TargetMachine; -class Pass; +class ModulePass; enum SparcV9InstrSchedClass { SPARC_NONE, /* Instructions with no scheduling restrictions */ @@ -91,7 +91,7 @@ protected: /// createStackSlotsPass - External interface to stack-slots pass that enters 2 /// empty slots at the top of each function stack /// -Pass *createStackSlotsPass(const TargetMachine &TM); +FunctionPass *createStackSlotsPass(const TargetMachine &TM); /// Specializes LLVM code for a target machine. /// @@ -111,7 +111,7 @@ FunctionPass* createPrologEpilogInsertionPass(); /// getBytecodeAsmPrinterPass - Emits final LLVM bytecode to assembly file. /// -Pass* createBytecodeAsmPrinterPass(std::ostream &Out); +ModulePass* createBytecodeAsmPrinterPass(std::ostream &Out); FunctionPass *createSparcV9MachineCodeDestructionPass(); diff --git a/lib/Target/SparcV9/SparcV9StackSlots.cpp b/lib/Target/SparcV9/SparcV9StackSlots.cpp index 90aca0d864..554a476d50 100644 --- a/lib/Target/SparcV9/SparcV9StackSlots.cpp +++ b/lib/Target/SparcV9/SparcV9StackSlots.cpp @@ -46,7 +46,7 @@ namespace { }; } -Pass *llvm::createStackSlotsPass(const TargetMachine &Target) { +FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) { return new StackSlots(Target); } diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 7b5def4284..85339bf9a7 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -75,7 +75,7 @@ namespace { "Promote 'by reference' arguments to scalars"); } -Pass *llvm::createArgumentPromotionPass() { +ModulePass *llvm::createArgumentPromotionPass() { return new ArgPromotion(); } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 9f3c10959c..27e1955ab2 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -26,19 +26,19 @@ using namespace llvm; namespace { Statistic<> NumMerged("constmerge", "Number of global constants merged"); - struct ConstantMerge : public Pass { + struct ConstantMerge : public ModulePass { // run - For this pass, process all of the globals in the module, // eliminating duplicate constants. // - bool run(Module &M); + bool runOnModule(Module &M); }; RegisterOpt X("constmerge","Merge Duplicate Global Constants"); } -Pass *llvm::createConstantMergePass() { return new ConstantMerge(); } +ModulePass *llvm::createConstantMergePass() { return new ConstantMerge(); } -bool ConstantMerge::run(Module &M) { +bool ConstantMerge::runOnModule(Module &M) { std::map CMap; // Replacements - This vector contains a list of replacements to perform. diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index cde186c38d..e4b7a3ee61 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -38,7 +38,7 @@ namespace { /// DAE - The dead argument elimination pass. /// - class DAE : public Pass { + class DAE : public ModulePass { /// Liveness enum - During our initial pass over the program, we determine /// that things are either definately alive, definately dead, or in need of /// interprocedural analysis (MaybeLive). @@ -75,7 +75,7 @@ namespace { std::multimap CallSites; public: - bool run(Module &M); + bool runOnModule(Module &M); virtual bool ShouldHackArguments() const { return false; } @@ -106,8 +106,8 @@ namespace { /// createDeadArgEliminationPass - This pass removes arguments from functions /// which are not used by the body of the function. /// -Pass *llvm::createDeadArgEliminationPass() { return new DAE(); } -Pass *llvm::createDeadArgHackingPass() { return new DAH(); } +ModulePass *llvm::createDeadArgEliminationPass() { return new DAE(); } +ModulePass *llvm::createDeadArgHackingPass() { return new DAH(); } static inline bool CallPassesValueThoughVararg(Instruction *Call, const Value *Arg) { @@ -484,7 +484,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { F->getParent()->getFunctionList().erase(F); } -bool DAE::run(Module &M) { +bool DAE::runOnModule(Module &M) { // First phase: loop through the module, determining which arguments are live. // We assume all arguments are dead unless proven otherwise (allowing us to // determine that dead arguments passed into recursive functions are dead). diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index e2d475daf9..9b1a919465 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -21,14 +21,14 @@ using namespace llvm; namespace { - struct DTE : public Pass { + struct DTE : public ModulePass { // 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. // // Also, initialize instance variables. // - bool run(Module &M); + bool runOnModule(Module &M); // getAnalysisUsage - This function needs FindUsedTypes to do its job... // @@ -41,7 +41,7 @@ namespace { NumKilled("deadtypeelim", "Number of unused typenames removed from symtab"); } -Pass *llvm::createDeadTypeEliminationPass() { +ModulePass *llvm::createDeadTypeEliminationPass() { return new DTE(); } @@ -65,7 +65,7 @@ static inline bool ShouldNukeSymtabEntry(const Type *Ty){ // uglier to look at, so we nuke them. Also eliminate types that are never used // in the entire program as indicated by FindUsedTypes. // -bool DTE::run(Module &M) { +bool DTE::runOnModule(Module &M) { bool Changed = false; SymbolTable &ST = M.getSymbolTable(); diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index 41b796035b..1b92fd1df8 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -17,7 +17,7 @@ using namespace llvm; namespace { - class FunctionExtractorPass : public Pass { + class FunctionExtractorPass : public ModulePass { Function *Named; bool deleteFunc; public: @@ -28,7 +28,7 @@ namespace { FunctionExtractorPass(Function *F = 0, bool deleteFn = true) : Named(F), deleteFunc(deleteFn) {} - bool run(Module &M) { + bool runOnModule(Module &M) { if (Named == 0) { Named = M.getMainFunction(); if (Named == 0) return false; // No function to extract @@ -112,6 +112,6 @@ namespace { RegisterPass X("extract", "Function Extractor"); } -Pass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) { +ModulePass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) { return new FunctionExtractorPass(F, deleteFn); } diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 006d33cf51..3450662181 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -35,17 +35,17 @@ namespace { Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved"); Statistic<> NumGlobals("funcresolve", "Number of global variables resolved"); - struct FunctionResolvingPass : public Pass { + struct FunctionResolvingPass : public ModulePass { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); } - bool run(Module &M); + bool runOnModule(Module &M); }; RegisterOpt X("funcresolve", "Resolve Functions"); } -Pass *llvm::createFunctionResolvingPass() { +ModulePass *llvm::createFunctionResolvingPass() { return new FunctionResolvingPass(); } @@ -293,7 +293,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD, return false; } -bool FunctionResolvingPass::run(Module &M) { +bool FunctionResolvingPass::runOnModule(Module &M) { std::map > Globals; // Loop over the globals, adding them to the Globals map. We use a two pass diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index ea5201cd23..cdf994aeb4 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -27,11 +27,11 @@ namespace { Statistic<> NumFunctions("globaldce","Number of functions removed"); Statistic<> NumVariables("globaldce","Number of global variables removed"); - struct GlobalDCE : public Pass { + struct GlobalDCE : public ModulePass { // run - Do the GlobalDCE pass on the specified module, optionally updating // the specified callgraph to reflect the changes. // - bool run(Module &M); + bool runOnModule(Module &M); private: std::set AliveGlobals; @@ -47,9 +47,9 @@ namespace { RegisterOpt X("globaldce", "Dead Global Elimination"); } -Pass *llvm::createGlobalDCEPass() { return new GlobalDCE(); } +ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCE(); } -bool GlobalDCE::run(Module &M) { +bool GlobalDCE::runOnModule(Module &M) { bool Changed = false; // Loop over the module, adding globals which are obviously necessary. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index dd9894cd19..f37be86e1e 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -31,14 +31,14 @@ using namespace llvm; namespace { Statistic<> NumMarked("constify", "Number of globals marked constant"); - struct Constifier : public Pass { - bool run(Module &M); + struct Constifier : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt X("constify", "Global Constifier"); } -Pass *llvm::createGlobalConstifierPass() { return new Constifier(); } +ModulePass *llvm::createGlobalConstifierPass() { return new Constifier(); } /// A lot of global constants are stored only in trivially dead setter /// functions. Because we don't want to cycle between globaldce and this pass, @@ -81,7 +81,7 @@ static bool isStoredThrough(Value *V, std::set &PHIUsers) { return false; } -bool Constifier::run(Module &M) { +bool Constifier::runOnModule(Module &M) { bool Changed = false; std::set PHIUsers; for (Module::giterator GV = M.gbegin(), E = M.gend(); GV != E; ++GV) diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index 74a0a9b699..64d1df8354 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -29,17 +29,17 @@ namespace { /// IPCP - The interprocedural constant propagation pass /// - struct IPCP : public Pass { - bool run(Module &M); + struct IPCP : public ModulePass { + bool runOnModule(Module &M); private: bool processFunction(Function &F); }; RegisterOpt X("ipconstprop", "Interprocedural constant propagation"); } -Pass *llvm::createIPConstantPropagationPass() { return new IPCP(); } +ModulePass *llvm::createIPConstantPropagationPass() { return new IPCP(); } -bool IPCP::run(Module &M) { +bool IPCP::runOnModule(Module &M) { bool Changed = false; bool LocalChange = true; diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 1722fe52e0..6a43143d87 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -66,7 +66,7 @@ namespace { RegisterOpt X("inline", "Function Integration/Inlining"); } -Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); } +ModulePass *llvm::createFunctionInliningPass() { return new SimpleInliner(); } // CountCodeReductionForConstant - Figure out an approximation for how many // instructions will be constant folded if the specified value is constant. diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index c6b75b1be9..5e436aa215 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -39,7 +39,7 @@ namespace { cl::desc("A list of symbol names to preserve"), cl::CommaSeparated); - class InternalizePass : public Pass { + class InternalizePass : public ModulePass { std::set ExternalNames; public: InternalizePass() { @@ -65,7 +65,7 @@ namespace { } } - virtual bool run(Module &M) { + virtual bool runOnModule(Module &M) { // If no list or file of symbols was specified, check to see if there is a // "main" symbol defined in the module. If so, use it, otherwise do not // internalize the module, it must be a library or something. @@ -117,6 +117,6 @@ namespace { RegisterOpt X("internalize", "Internalize Global Symbols"); } // end anonymous namespace -Pass *llvm::createInternalizePass() { +ModulePass *llvm::createInternalizePass() { return new InternalizePass(); } diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index e1ce290526..1bdb5c272a 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -126,7 +126,7 @@ bool LoopExtractor::runOnFunction(Function &F) { // createSingleLoopExtractorPass - This pass extracts one natural loop from the // program into a function if it can. This is used by bugpoint. // -Pass *llvm::createSingleLoopExtractorPass() { +ModulePass *llvm::createSingleLoopExtractorPass() { return new SingleLoopExtractor(); } @@ -135,13 +135,13 @@ namespace { /// BlockExtractorPass - This pass is used by bugpoint to extract all blocks /// from the module into their own functions except for those specified by the /// BlocksToNotExtract list. - class BlockExtractorPass : public Pass { + class BlockExtractorPass : public ModulePass { std::vector BlocksToNotExtract; public: BlockExtractorPass(std::vector &B) : BlocksToNotExtract(B) {} BlockExtractorPass() {} - bool run(Module &M); + bool runOnModule(Module &M); }; RegisterOpt XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)"); @@ -150,11 +150,11 @@ namespace { // createBlockExtractorPass - This pass extracts all blocks (except those // specified in the argument list) from the functions in the module. // -Pass *llvm::createBlockExtractorPass(std::vector &BTNE) { +ModulePass *llvm::createBlockExtractorPass(std::vector &BTNE) { return new BlockExtractorPass(BTNE); } -bool BlockExtractorPass::run(Module &M) { +bool BlockExtractorPass::runOnModule(Module &M) { std::set TranslatedBlocksToNotExtract; for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) { BasicBlock *BB = BlocksToNotExtract[i]; diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index ebd0500cba..4ad89b583c 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -64,7 +64,7 @@ namespace { // class because it works on a module as a whole, not a function at a // time. - class LowerSetJmp : public Pass, + class LowerSetJmp : public ModulePass, public InstVisitor { // LLVM library functions... Function* InitSJMap; // __llvm_sjljeh_init_setjmpmap @@ -119,7 +119,7 @@ namespace { void visitReturnInst(ReturnInst& RI); void visitUnwindInst(UnwindInst& UI); - bool run(Module& M); + bool runOnModule(Module& M); bool doInitialization(Module& M); }; @@ -129,8 +129,7 @@ namespace { // run - Run the transformation on the program. We grab the function // prototypes for longjmp and setjmp. If they are used in the program, // then we can go directly to the places they're at and transform them. -bool LowerSetJmp::run(Module& M) -{ +bool LowerSetJmp::runOnModule(Module& M) { bool Changed = false; // These are what the functions are called. @@ -509,8 +508,7 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II) // visitReturnInst - We want to destroy the setjmp map upon exit from the // function. -void LowerSetJmp::visitReturnInst(ReturnInst& RI) -{ +void LowerSetJmp::visitReturnInst(ReturnInst &RI) { Function* Func = RI.getParent()->getParent(); new CallInst(DestroySJMap, make_vector(GetSetJmpMap(Func), 0), "", &RI); @@ -518,15 +516,13 @@ void LowerSetJmp::visitReturnInst(ReturnInst& RI) // visitUnwindInst - We want to destroy the setjmp map upon exit from the // function. -void LowerSetJmp::visitUnwindInst(UnwindInst& UI) -{ +void LowerSetJmp::visitUnwindInst(UnwindInst &UI) { Function* Func = UI.getParent()->getParent(); new CallInst(DestroySJMap, make_vector(GetSetJmpMap(Func), 0), "", &UI); } -Pass* llvm::createLowerSetJmpPass() -{ +ModulePass *llvm::createLowerSetJmpPass() { return new LowerSetJmp(); } diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 43b9acff73..36423c8e3e 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -38,7 +38,7 @@ namespace { RegisterOpt X("prune-eh", "Remove unused exception handling info"); } -Pass *llvm::createPruneEHPass() { return new PruneEH(); } +ModulePass *llvm::createPruneEHPass() { return new PruneEH(); } bool PruneEH::runOnSCC(const std::vector &SCC) { diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 42edb7e05d..d91d23fd18 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -28,7 +28,7 @@ namespace { // RaiseAllocations - Turn %malloc and %free calls into the appropriate // instruction. // - class RaiseAllocations : public Pass { + class RaiseAllocations : public ModulePass { Function *MallocFunc; // Functions in the module we are processing Function *FreeFunc; // Initialized by doPassInitializationVirt public: @@ -41,7 +41,7 @@ namespace { // run - This method does the actual work of converting instructions over. // - bool run(Module &M); + bool runOnModule(Module &M); }; RegisterOpt @@ -50,7 +50,7 @@ namespace { // createRaiseAllocationsPass - The interface to this file... -Pass *llvm::createRaiseAllocationsPass() { +ModulePass *llvm::createRaiseAllocationsPass() { return new RaiseAllocations(); } @@ -114,7 +114,7 @@ void RaiseAllocations::doInitialization(Module &M) { // run - Transform calls into instructions... // -bool RaiseAllocations::run(Module &M) { +bool RaiseAllocations::runOnModule(Module &M) { // Find the malloc/free prototypes... doInitialization(M); diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index e357e841cd..f22f81feef 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -29,15 +29,15 @@ using namespace llvm; namespace { - class FunctionProfiler : public Pass { - bool run(Module &M); + class FunctionProfiler : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt X("insert-function-profiling", "Insert instrumentation for function profiling"); } -bool FunctionProfiler::run(Module &M) { +bool FunctionProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { std::cerr << "WARNING: cannot insert function profiling into a module" @@ -69,15 +69,15 @@ bool FunctionProfiler::run(Module &M) { namespace { - class BlockProfiler : public Pass { - bool run(Module &M); + class BlockProfiler : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt Y("insert-block-profiling", "Insert instrumentation for block profiling"); } -bool BlockProfiler::run(Module &M) { +bool BlockProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { std::cerr << "WARNING: cannot insert block profiling into a module" diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp index c584ca5dfe..89c540c5bc 100644 --- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -28,15 +28,15 @@ using namespace llvm; namespace { - class EdgeProfiler : public Pass { - bool run(Module &M); + class EdgeProfiler : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt X("insert-edge-profiling", "Insert instrumentation for edge profiling"); } -bool EdgeProfiler::run(Module &M) { +bool EdgeProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { std::cerr << "WARNING: cannot insert edge profiling into a module" diff --git a/lib/Transforms/Instrumentation/EmitFunctions.cpp b/lib/Transforms/Instrumentation/EmitFunctions.cpp index a1c23dab23..92abffb8ea 100644 --- a/lib/Transforms/Instrumentation/EmitFunctions.cpp +++ b/lib/Transforms/Instrumentation/EmitFunctions.cpp @@ -27,8 +27,8 @@ namespace { BLACK }; - struct EmitFunctionTable : public Pass { - bool run(Module &M); + struct EmitFunctionTable : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt @@ -64,7 +64,7 @@ static char hasBackEdge(Function *F){ } // Per Module pass for inserting function table -bool EmitFunctionTable::run(Module &M){ +bool EmitFunctionTable::runOnModule(Module &M){ std::vector vType; std::vector vConsts; diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp index 60426c4e5a..746e82221a 100644 --- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp +++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp @@ -25,8 +25,8 @@ using namespace llvm; namespace { - class TraceBasicBlocks : public Pass { - bool run(Module &M); + class TraceBasicBlocks : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt X("trace-basic-blocks", @@ -52,7 +52,7 @@ static void InsertInstrumentationCall (BasicBlock *BB, Instruction *InstrCall = new CallInst (InstrFn, Args, "", InsertPos); } -bool TraceBasicBlocks::run(Module &M) { +bool TraceBasicBlocks::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { std::cerr << "WARNING: cannot insert basic-block trace instrumentation" diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 95e0f563c9..1d8267fe4e 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -726,9 +726,9 @@ template<> struct PassManagerTraits : public FunctionPass { // // This is the top level PassManager implementation that holds generic passes. // -template<> struct PassManagerTraits : public Pass { +template<> struct PassManagerTraits : public ModulePass { // PassClass - The type of passes tracked by this PassManager - typedef Pass PassClass; + typedef ModulePass PassClass; // SubPassClass - The types of classes that should be collated together typedef FunctionPass SubPassClass; @@ -740,15 +740,15 @@ template<> struct PassManagerTraits : public Pass { typedef AnalysisResolver ParentClass; // runPass - Specify how the pass should be run on the UnitType - static bool runPass(PassClass *P, Module *M) { return P->run(*M); } + static bool runPass(PassClass *P, Module *M) { return P->runOnModule(*M); } // getPMName() - Return the name of the unit the PassManager operates on for // debugging. const char *getPMName() const { return "Module"; } virtual const char *getPassName() const { return "Module Pass Manager"; } - // run - Implement the PassManager interface... - bool run(Module &M) { + // runOnModule - Implement the PassManager interface. + bool runOnModule(Module &M) { return ((PassManagerT*)this)->runOnUnit(&M); } }; diff --git a/tools/analyze/AnalysisWrappers.cpp b/tools/analyze/AnalysisWrappers.cpp index a0520d4a4a..46ede0a153 100644 --- a/tools/analyze/AnalysisWrappers.cpp +++ b/tools/analyze/AnalysisWrappers.cpp @@ -28,8 +28,8 @@ namespace { /// external functions that are called with constant arguments. This can be /// useful when looking for standard library functions we should constant fold /// or handle in alias analyses. - struct ExternalFunctionsPassedConstants : public Pass { - virtual bool run(Module &M) { + struct ExternalFunctionsPassedConstants : public ModulePass { + virtual bool runOnModule(Module &M) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (I->isExternal()) { bool PrintedFn = false; diff --git a/tools/analyze/GraphPrinters.cpp b/tools/analyze/GraphPrinters.cpp index 1176a8df10..9fd09c94fd 100644 --- a/tools/analyze/GraphPrinters.cpp +++ b/tools/analyze/GraphPrinters.cpp @@ -58,8 +58,8 @@ namespace llvm { namespace { - struct CallGraphPrinter : public Pass { - virtual bool run(Module &M) { + struct CallGraphPrinter : public ModulePass { + virtual bool runOnModule(Module &M) { WriteGraphToFile(std::cerr, "callgraph", &getAnalysis()); return false; } diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 1542a1a068..5a0c9508f6 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -30,11 +30,11 @@ using namespace llvm; -struct ModulePassPrinter : public Pass { +struct ModulePassPrinter : public ModulePass { const PassInfo *PassToPrint; ModulePassPrinter(const PassInfo *PI) : PassToPrint(PI) {} - virtual bool run(Module &M) { + virtual bool runOnModule(Module &M) { std::cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n"; getAnalysisID(PassToPrint).print(std::cout, &M); diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index cf02ef73a9..d65736a1ea 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -211,14 +211,14 @@ namespace { /// BlockExtractorPass - This pass is used by bugpoint to extract all blocks /// from the module into their own functions except for those specified by the /// BlocksToNotExtract list. - class BlockExtractorPass : public Pass { - bool run(Module &M); + class BlockExtractorPass : public ModulePass { + bool runOnModule(Module &M); }; RegisterOpt XX("extract-bbs", "Extract Basic Blocks From Module (for bugpoint use)"); } -bool BlockExtractorPass::run(Module &M) { +bool BlockExtractorPass::runOnModule(Module &M) { std::set TranslatedBlocksToNotExtract; for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) { BasicBlock *BB = BlocksToNotExtract[i]; diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp index a0520d4a4a..46ede0a153 100644 --- a/tools/opt/AnalysisWrappers.cpp +++ b/tools/opt/AnalysisWrappers.cpp @@ -28,8 +28,8 @@ namespace { /// external functions that are called with constant arguments. This can be /// useful when looking for standard library functions we should constant fold /// or handle in alias analyses. - struct ExternalFunctionsPassedConstants : public Pass { - virtual bool run(Module &M) { + struct ExternalFunctionsPassedConstants : public ModulePass { + virtual bool runOnModule(Module &M) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (I->isExternal()) { bool PrintedFn = false; diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index 1176a8df10..9fd09c94fd 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -58,8 +58,8 @@ namespace llvm { namespace { - struct CallGraphPrinter : public Pass { - virtual bool run(Module &M) { + struct CallGraphPrinter : public ModulePass { + virtual bool runOnModule(Module &M) { WriteGraphToFile(std::cerr, "callgraph", &getAnalysis()); return false; } -- cgit v1.2.3