[llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp ConstantMerge.cpp DeadArgumentElimination.cpp DeadTypeElimination.cpp ExtractFunction.cpp FunctionResolution.cpp GlobalConstifier.cpp GlobalDCE.cpp IPConstantPropagation.cpp InlineSimple.cpp Internalize.cpp LoopExtractor.cpp LowerSetJmp.cpp PruneEH.cpp RaiseAllocations.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Sep 19 21:43:45 PDT 2004



Changes in directory llvm/lib/Transforms/IPO:

ArgumentPromotion.cpp updated: 1.12 -> 1.13
ConstantMerge.cpp updated: 1.27 -> 1.28
DeadArgumentElimination.cpp updated: 1.18 -> 1.19
DeadTypeElimination.cpp updated: 1.52 -> 1.53
ExtractFunction.cpp updated: 1.9 -> 1.10
FunctionResolution.cpp updated: 1.52 -> 1.53
GlobalConstifier.cpp updated: 1.7 -> 1.8
GlobalDCE.cpp updated: 1.34 -> 1.35
IPConstantPropagation.cpp updated: 1.8 -> 1.9
InlineSimple.cpp updated: 1.64 -> 1.65
Internalize.cpp updated: 1.22 -> 1.23
LoopExtractor.cpp updated: 1.14 -> 1.15
LowerSetJmp.cpp updated: 1.19 -> 1.20
PruneEH.cpp updated: 1.15 -> 1.16
RaiseAllocations.cpp updated: 1.25 -> 1.26
---
Log message:

'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.


---
Diffs of the changes:  (+53 -57)

Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.12 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.13
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.12	Sat Sep 18 20:05:16 2004
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp	Sun Sep 19 23:43:34 2004
@@ -75,7 +75,7 @@
                               "Promote 'by reference' arguments to scalars");
 }
 
-Pass *llvm::createArgumentPromotionPass() {
+ModulePass *llvm::createArgumentPromotionPass() {
   return new ArgPromotion();
 }
 


Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff -u llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.27 llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.28
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.27	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp	Sun Sep 19 23:43:34 2004
@@ -26,19 +26,19 @@
 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<ConstantMerge> 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<Constant*, GlobalVariable*> CMap;
 
   // Replacements - This vector contains a list of replacements to perform.


Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.18 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.19
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.18	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp	Sun Sep 19 23:43:34 2004
@@ -38,7 +38,7 @@
 
   /// 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 @@
     std::multimap<Function*, CallSite> CallSites;
 
   public:
-    bool run(Module &M);
+    bool runOnModule(Module &M);
 
     virtual bool ShouldHackArguments() const { return false; }
 
@@ -106,8 +106,8 @@
 /// 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 @@
   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).


Index: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.52 llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.53
--- llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.52	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/DeadTypeElimination.cpp	Sun Sep 19 23:43:34 2004
@@ -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 @@
   NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
 }
 
-Pass *llvm::createDeadTypeEliminationPass() {
+ModulePass *llvm::createDeadTypeEliminationPass() {
   return new DTE();
 }
 
@@ -65,7 +65,7 @@
 // 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();


Index: llvm/lib/Transforms/IPO/ExtractFunction.cpp
diff -u llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.9 llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.10
--- llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.9	Thu Apr 22 18:00:51 2004
+++ llvm/lib/Transforms/IPO/ExtractFunction.cpp	Sun Sep 19 23:43:34 2004
@@ -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 @@
     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 @@
   RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor");
 }
 
-Pass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) {
+ModulePass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) {
   return new FunctionExtractorPass(F, deleteFn);
 }


Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.52 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.53
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.52	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Sun Sep 19 23:43:34 2004
@@ -35,17 +35,17 @@
   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<TargetData>();
     }
 
-    bool run(Module &M);
+    bool runOnModule(Module &M);
   };
   RegisterOpt<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
 }
 
-Pass *llvm::createFunctionResolvingPass() {
+ModulePass *llvm::createFunctionResolvingPass() {
   return new FunctionResolvingPass();
 }
 
@@ -293,7 +293,7 @@
   return false;
 }
 
-bool FunctionResolvingPass::run(Module &M) {
+bool FunctionResolvingPass::runOnModule(Module &M) {
   std::map<std::string, std::vector<GlobalValue*> > Globals;
 
   // Loop over the globals, adding them to the Globals map.  We use a two pass


Index: llvm/lib/Transforms/IPO/GlobalConstifier.cpp
diff -u llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.7 llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.8
--- llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.7	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/GlobalConstifier.cpp	Sun Sep 19 23:43:34 2004
@@ -31,14 +31,14 @@
 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<Constifier> 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 @@
   return false;
 }
 
-bool Constifier::run(Module &M) {
+bool Constifier::runOnModule(Module &M) {
   bool Changed = false;
   std::set<PHINode*> PHIUsers;
   for (Module::giterator GV = M.gbegin(), E = M.gend(); GV != E; ++GV)


Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.34 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.35
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.34	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp	Sun Sep 19 23:43:34 2004
@@ -27,11 +27,11 @@
   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<GlobalValue*> AliveGlobals;
@@ -47,9 +47,9 @@
   RegisterOpt<GlobalDCE> 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) {


Index: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
diff -u llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.8 llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.9
--- llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.8	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/IPConstantPropagation.cpp	Sun Sep 19 23:43:34 2004
@@ -29,17 +29,17 @@
 
   /// 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<IPCP> 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;
 


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.64 llvm/lib/Transforms/IPO/InlineSimple.cpp:1.65
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.64	Thu Aug 12 00:45:09 2004
+++ llvm/lib/Transforms/IPO/InlineSimple.cpp	Sun Sep 19 23:43:34 2004
@@ -66,7 +66,7 @@
   RegisterOpt<SimpleInliner> 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.


Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.22 llvm/lib/Transforms/IPO/Internalize.cpp:1.23
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.22	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/Internalize.cpp	Sun Sep 19 23:43:34 2004
@@ -39,7 +39,7 @@
           cl::desc("A list of symbol names to preserve"),
           cl::CommaSeparated);
  
-  class InternalizePass : public Pass {
+  class InternalizePass : public ModulePass {
     std::set<std::string> ExternalNames;
   public:
     InternalizePass() {
@@ -65,7 +65,7 @@
       }
     }
 
-    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 @@
   RegisterOpt<InternalizePass> X("internalize", "Internalize Global Symbols");
 } // end anonymous namespace
 
-Pass *llvm::createInternalizePass() {
+ModulePass *llvm::createInternalizePass() {
   return new InternalizePass();
 }


Index: llvm/lib/Transforms/IPO/LoopExtractor.cpp
diff -u llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.14 llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.15
--- llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.14	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/LoopExtractor.cpp	Sun Sep 19 23:43:34 2004
@@ -126,7 +126,7 @@
 // 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 @@
   /// 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<BasicBlock*> BlocksToNotExtract;
   public:
     BlockExtractorPass(std::vector<BasicBlock*> &B) : BlocksToNotExtract(B) {}
     BlockExtractorPass() {}
 
-    bool run(Module &M);
+    bool runOnModule(Module &M);
   };
   RegisterOpt<BlockExtractorPass>
   XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)");
@@ -150,11 +150,11 @@
 // createBlockExtractorPass - This pass extracts all blocks (except those
 // specified in the argument list) from the functions in the module.
 //
-Pass *llvm::createBlockExtractorPass(std::vector<BasicBlock*> &BTNE) {
+ModulePass *llvm::createBlockExtractorPass(std::vector<BasicBlock*> &BTNE) {
   return new BlockExtractorPass(BTNE);
 }
 
-bool BlockExtractorPass::run(Module &M) {
+bool BlockExtractorPass::runOnModule(Module &M) {
   std::set<BasicBlock*> TranslatedBlocksToNotExtract;
   for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) {
     BasicBlock *BB = BlocksToNotExtract[i];


Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp
diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.19 llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.20
--- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.19	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp	Sun Sep 19 23:43:34 2004
@@ -64,7 +64,7 @@
   // 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<LowerSetJmp> {
     // LLVM library functions...
     Function* InitSJMap;        // __llvm_sjljeh_init_setjmpmap
@@ -119,7 +119,7 @@
     void visitReturnInst(ReturnInst& RI);
     void visitUnwindInst(UnwindInst& UI);
 
-    bool run(Module& M);
+    bool runOnModule(Module& M);
     bool doInitialization(Module& M);
   };
 
@@ -129,8 +129,7 @@
 // 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 @@
 
 // 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<Value*>(GetSetJmpMap(Func), 0),
                "", &RI);
@@ -518,15 +516,13 @@
 
 // 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<Value*>(GetSetJmpMap(Func), 0),
                "", &UI);
 }
 
-Pass* llvm::createLowerSetJmpPass()
-{
+ModulePass *llvm::createLowerSetJmpPass() {
   return new LowerSetJmp();
 }
 


Index: llvm/lib/Transforms/IPO/PruneEH.cpp
diff -u llvm/lib/Transforms/IPO/PruneEH.cpp:1.15 llvm/lib/Transforms/IPO/PruneEH.cpp:1.16
--- llvm/lib/Transforms/IPO/PruneEH.cpp:1.15	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/PruneEH.cpp	Sun Sep 19 23:43:34 2004
@@ -38,7 +38,7 @@
   RegisterOpt<PruneEH> 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<CallGraphNode *> &SCC) {


Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp
diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.25 llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.26
--- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.25	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/IPO/RaiseAllocations.cpp	Sun Sep 19 23:43:34 2004
@@ -28,7 +28,7 @@
   // 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 @@
     
     // run - This method does the actual work of converting instructions over.
     //
-    bool run(Module &M);
+    bool runOnModule(Module &M);
   };
   
   RegisterOpt<RaiseAllocations>
@@ -50,7 +50,7 @@
 
 
 // createRaiseAllocationsPass - The interface to this file...
-Pass *llvm::createRaiseAllocationsPass() {
+ModulePass *llvm::createRaiseAllocationsPass() {
   return new RaiseAllocations();
 }
 
@@ -114,7 +114,7 @@
 
 // run - Transform calls into instructions...
 //
-bool RaiseAllocations::run(Module &M) {
+bool RaiseAllocations::runOnModule(Module &M) {
   // Find the malloc/free prototypes...
   doInitialization(M);
 






More information about the llvm-commits mailing list