diff options
author | Devang Patel <dpatel@apple.com> | 2007-05-01 21:15:47 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-05-01 21:15:47 +0000 |
commit | 794fd75c67a2cdc128d67342c6d88a504d186896 (patch) | |
tree | 6b805aa4a576e9de6cbf096d2fb85063b3fb8fca /lib/Transforms | |
parent | e50fb9ac174b791047ffa8648443ab94b2097cd9 (diff) |
Do not use typeinfo to identify pass in pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
60 files changed, 260 insertions, 18 deletions
diff --git a/lib/Transforms/Hello/Hello.cpp b/lib/Transforms/Hello/Hello.cpp index df8866279f..d9af9df18b 100644 --- a/lib/Transforms/Hello/Hello.cpp +++ b/lib/Transforms/Hello/Hello.cpp @@ -25,6 +25,9 @@ STATISTIC(HelloCounter, "Counts number of functions greeted"); namespace { // Hello - The first implementation, without getAnalysisUsage. struct Hello : public FunctionPass { + static const int ID; // Pass identifcation, replacement for typeid + Hello() : FunctionPass((intptr_t)&ID) {} + virtual bool runOnFunction(Function &F) { HelloCounter++; std::string fname = F.getName(); @@ -33,10 +36,15 @@ namespace { return false; } }; + + const int Hello::ID = 0; RegisterPass<Hello> X("hello", "Hello World Pass"); // Hello2 - The second implementation with getAnalysisUsage implemented. struct Hello2 : public FunctionPass { + static const int ID; // Pass identifcation, replacement for typeid + Hello2() : FunctionPass((intptr_t)&ID) {} + virtual bool runOnFunction(Function &F) { HelloCounter++; std::string fname = F.getName(); @@ -50,6 +58,7 @@ namespace { AU.setPreservesAll(); }; }; + const int Hello2::ID = 0; RegisterPass<Hello2> Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)"); } diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index e1fe118686..6310e5dc0f 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -63,12 +63,16 @@ namespace { } virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC); + static const int ID; // Pass identifcation, replacement for typeid + ArgPromotion() : CallGraphSCCPass((intptr_t)&ID) {} + private: bool PromoteArguments(CallGraphNode *CGN); bool isSafeToPromoteArgument(Argument *Arg) const; Function *DoPromotion(Function *F, std::vector<Argument*> &ArgsToPromote); }; + const int ArgPromotion::ID = 0; RegisterPass<ArgPromotion> X("argpromotion", "Promote 'by reference' arguments to scalars"); } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 400b5e2031..5c226438c2 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -29,12 +29,16 @@ STATISTIC(NumMerged, "Number of global constants merged"); namespace { struct VISIBILITY_HIDDEN ConstantMerge : public ModulePass { + static const int ID; // Pass identifcation, replacement for typeid + ConstantMerge() : ModulePass((intptr_t)&ID) {} + // run - For this pass, process all of the globals in the module, // eliminating duplicate constants. // bool runOnModule(Module &M); }; + const int ConstantMerge::ID = 0; RegisterPass<ConstantMerge>X("constmerge","Merge Duplicate Global Constants"); } diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index d0dbc8b428..162d078514 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -76,6 +76,8 @@ namespace { std::multimap<Function*, CallSite> CallSites; public: + static const int ID; // Pass identifcation, replacement for typeid + DAE() : ModulePass((intptr_t)&ID) {} bool runOnModule(Module &M); virtual bool ShouldHackArguments() const { return false; } @@ -93,14 +95,17 @@ namespace { void RemoveDeadArgumentsFromFunction(Function *F); }; + const int DAE::ID = 0; RegisterPass<DAE> X("deadargelim", "Dead Argument Elimination"); /// DAH - DeadArgumentHacking pass - Same as dead argument elimination, but /// deletes arguments to functions which are external. This is only for use /// by bugpoint. struct DAH : public DAE { + static const int ID; virtual bool ShouldHackArguments() const { return true; } }; + const int DAH::ID = 0; RegisterPass<DAH> Y("deadarghaX0r", "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)"); } diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index a72a48cc63..8ecd4b7688 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -26,6 +26,9 @@ STATISTIC(NumKilled, "Number of unused typenames removed from symtab"); namespace { struct VISIBILITY_HIDDEN DTE : public ModulePass { + static const int ID; // Pass identifcation, replacement for typeid + DTE() : ModulePass((intptr_t)&ID) {} + // 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. @@ -40,6 +43,7 @@ namespace { AU.addRequired<FindUsedTypes>(); } }; + const int DTE::ID = 0; RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination"); } diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index afaf38d280..7a4765533e 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -25,13 +25,16 @@ namespace { bool deleteFunc; bool reLink; public: + static const int ID; // Pass identifcation, replacement for typeid + /// FunctionExtractorPass - If deleteFn is true, this pass deletes as the /// specified function. Otherwise, it deletes as much of the module as /// possible, except for the function specified. /// FunctionExtractorPass(Function *F = 0, bool deleteFn = true, bool relinkCallees = false) - : Named(F), deleteFunc(deleteFn), reLink(relinkCallees) {} + : ModulePass((intptr_t)&ID), Named(F), deleteFunc(deleteFn), + reLink(relinkCallees) {} bool runOnModule(Module &M) { if (Named == 0) { @@ -131,6 +134,7 @@ namespace { } }; + const int FunctionExtractorPass::ID = 0; RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor"); } diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 56879e2b13..00b16a839e 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -30,6 +30,9 @@ STATISTIC(NumVariables, "Number of global variables removed"); namespace { struct VISIBILITY_HIDDEN GlobalDCE : public ModulePass { + static const int ID; // Pass identifcation, replacement for typeid + GlobalDCE() : ModulePass((intptr_t)&ID) {} + // run - Do the GlobalDCE pass on the specified module, optionally updating // the specified callgraph to reflect the changes. // @@ -46,6 +49,7 @@ namespace { bool SafeToDestroyConstant(Constant* C); bool RemoveUnusedGlobalValue(GlobalValue &GV); }; + const int GlobalDCE::ID = 0; RegisterPass<GlobalDCE> X("globaldce", "Dead Global Elimination"); } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 9ac3654870..cfa8998b2f 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -50,6 +50,8 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<TargetData>(); } + static const int ID; // Pass identifcation, replacement for typeid + GlobalOpt() : ModulePass((intptr_t)&ID) {} bool runOnModule(Module &M); @@ -61,6 +63,7 @@ namespace { bool ProcessInternalGlobal(GlobalVariable *GV,Module::global_iterator &GVI); }; + const int GlobalOpt::ID = 0; RegisterPass<GlobalOpt> X("globalopt", "Global Variable Optimizer"); } diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index af4fb69c82..9ef775660a 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -33,11 +33,15 @@ namespace { /// IPCP - The interprocedural constant propagation pass /// struct VISIBILITY_HIDDEN IPCP : public ModulePass { + static const int ID; // Pass identifcation, replacement for typeid + IPCP() : ModulePass((intptr_t)&ID) {} + bool runOnModule(Module &M); private: bool PropagateConstantsIntoArguments(Function &F); bool PropagateConstantReturn(Function &F); }; + const int IPCP::ID = 0; RegisterPass<IPCP> X("ipconstprop", "Interprocedural constant propagation"); } diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index eeddad71a9..20d11178bf 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -32,8 +32,12 @@ STATISTIC(NumBounce , "Number of bounce functions created"); namespace { class VISIBILITY_HIDDEN IndMemRemPass : public ModulePass { public: + static const int ID; // Pass identifcation, replacement for typeid + IndMemRemPass() : ModulePass((intptr_t)&ID) {} + virtual bool runOnModule(Module &M); }; + const int IndMemRemPass::ID = 0; RegisterPass<IndMemRemPass> X("indmemrem","Indirect Malloc and Free Removal"); } // end anonymous namespace diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 64de9c395e..8f9a1f64d9 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -54,8 +54,10 @@ namespace { class VISIBILITY_HIDDEN SimpleInliner : public Inliner { std::map<const Function*, FunctionInfo> CachedFunctionInfo; public: + static const int ID; // Pass identifcation, replacement for typeid int getInlineCost(CallSite CS); }; + const int SimpleInliner::ID = 0; RegisterPass<SimpleInliner> X("inline", "Function Integration/Inlining"); } diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 5990b65837..82611cbc8f 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -36,7 +36,9 @@ namespace { cl::desc("Control the amount of inlining to perform (default = 200)")); } -Inliner::Inliner() : InlineThreshold(InlineLimit) {} +const int Inliner::ID = 0; +Inliner::Inliner() + : CallGraphSCCPass((intptr_t)&ID), InlineThreshold(InlineLimit) {} /// getAnalysisUsage - For this class, we declare that we require and preserve /// the call graph. If the derived class implements this method, it should diff --git a/lib/Transforms/IPO/Inliner.h b/lib/Transforms/IPO/Inliner.h index a59f80b86d..321a65f488 100644 --- a/lib/Transforms/IPO/Inliner.h +++ b/lib/Transforms/IPO/Inliner.h @@ -27,6 +27,7 @@ namespace llvm { /// perform the inlining operations that does not depend on the policy. /// struct Inliner : public CallGraphSCCPass { + static const int ID; Inliner(); /// getAnalysisUsage - For this class, we declare that we require and preserve diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 46d80e592f..17de131590 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -46,16 +46,18 @@ namespace { std::set<std::string> ExternalNames; bool DontInternalize; public: + static const int ID; // Pass identifcation, replacement for typeid InternalizePass(bool InternalizeEverything = true); InternalizePass(const std::vector <const char *>& exportList); void LoadFile(const char *Filename); virtual bool runOnModule(Module &M); }; + const int InternalizePass::ID = 0; RegisterPass<InternalizePass> X("internalize", "Internalize Global Symbols"); } // end anonymous namespace InternalizePass::InternalizePass(bool InternalizeEverything) - : DontInternalize(false){ + : ModulePass((intptr_t)&ID), DontInternalize(false){ if (!APIFile.empty()) // If a filename is specified, use it LoadFile(APIFile.c_str()); else if (!APIList.empty()) // Else, if a list is specified, use it. @@ -66,7 +68,7 @@ InternalizePass::InternalizePass(bool InternalizeEverything) } InternalizePass::InternalizePass(const std::vector<const char *>&exportList) - : DontInternalize(false){ + : ModulePass((intptr_t)&ID), DontInternalize(false){ for(std::vector<const char *>::const_iterator itr = exportList.begin(); itr != exportList.end(); itr++) { ExternalNames.insert(*itr); diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index c5f4fca12a..0ea544daa6 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -34,9 +34,11 @@ namespace { // Module passes to require FunctionPasses, so we can't get loop info if we're // not a function pass. struct VISIBILITY_HIDDEN LoopExtractor : public FunctionPass { + static const int ID; // Pass identifcation, replacement for typeid unsigned NumLoops; - LoopExtractor(unsigned numLoops = ~0) : NumLoops(numLoops) {} + LoopExtractor(unsigned numLoops = ~0) + : FunctionPass((intptr_t)&ID), NumLoops(numLoops) {} virtual bool runOnFunction(Function &F); @@ -49,14 +51,17 @@ namespace { } }; + const int LoopExtractor::ID = 0; RegisterPass<LoopExtractor> X("loop-extract", "Extract loops into new functions"); /// SingleLoopExtractor - For bugpoint. struct SingleLoopExtractor : public LoopExtractor { + static const int ID; // Pass identifcation, replacement for typeid SingleLoopExtractor() : LoopExtractor(1) {} }; + const int SingleLoopExtractor::ID = 0; RegisterPass<SingleLoopExtractor> Y("loop-extract-single", "Extract at most one loop into a new function"); } // End anonymous namespace @@ -147,11 +152,15 @@ namespace { class BlockExtractorPass : public ModulePass { std::vector<BasicBlock*> BlocksToNotExtract; public: - BlockExtractorPass(std::vector<BasicBlock*> &B) : BlocksToNotExtract(B) {} - BlockExtractorPass() {} + static const int ID; // Pass identifcation, replacement for typeid + BlockExtractorPass(std::vector<BasicBlock*> &B) + : ModulePass((intptr_t)&ID), BlocksToNotExtract(B) {} + BlockExtractorPass() : ModulePass((intptr_t)&ID) {} bool runOnModule(Module &M); }; + + const int BlockExtractorPass::ID = 0; RegisterPass<BlockExtractorPass> XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)"); } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 3f32c0c76d..010bc592af 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -109,6 +109,9 @@ namespace { bool IsTransformableFunction(const std::string& Name); public: + static const int ID; // Pass identifcation, replacement for typeid + LowerSetJmp() : ModulePass((intptr_t)&ID) {} + void visitCallInst(CallInst& CI); void visitInvokeInst(InvokeInst& II); void visitReturnInst(ReturnInst& RI); @@ -118,6 +121,7 @@ namespace { bool doInitialization(Module& M); }; + const int LowerSetJmp::ID = 0; RegisterPass<LowerSetJmp> X("lowersetjmp", "Lower Set Jump"); } // end anonymous namespace diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 6040379d58..ee37992d16 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -35,6 +35,9 @@ STATISTIC(NumUnreach, "Number of noreturn calls optimized"); namespace { struct VISIBILITY_HIDDEN PruneEH : public CallGraphSCCPass { + static const int ID; // Pass identifcation, replacement for typeid + PruneEH() : CallGraphSCCPass((intptr_t)&ID) {} + /// DoesNotUnwind - This set contains all of the functions which we have /// determined cannot unwind. std::set<CallGraphNode*> DoesNotUnwind; @@ -49,6 +52,8 @@ namespace { bool SimplifyFunction(Function *F); void DeleteBasicBlock(BasicBlock *BB); }; + + const int PruneEH::ID = 0; RegisterPass<PruneEH> X("prune-eh", "Remove unused exception handling info"); } diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index ce6db5624a..f7f40377f0 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -35,7 +35,9 @@ namespace { Function *MallocFunc; // Functions in the module we are processing Function *FreeFunc; // Initialized by doPassInitializationVirt public: - RaiseAllocations() : MallocFunc(0), FreeFunc(0) {} + static const int ID; // Pass identifcation, replacement for typeid + RaiseAllocations() + : ModulePass((intptr_t)&ID), MallocFunc(0), FreeFunc(0) {} // doPassInitialization - For the raise allocations pass, this finds a // declaration for malloc and free if they exist. @@ -47,6 +49,7 @@ namespace { bool runOnModule(Module &M); }; + const int RaiseAllocations::ID = 0; RegisterPass<RaiseAllocations> X("raiseallocs", "Raise allocations from calls to instructions"); } // end anonymous namespace diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 5900a0254f..f5a8fee387 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -152,6 +152,9 @@ public: /// @brief A ModulePass for optimizing well-known function calls. class VISIBILITY_HIDDEN SimplifyLibCalls : public ModulePass { public: + static const int ID; // Pass identifcation, replacement for typeid + SimplifyLibCalls() : ModulePass((intptr_t)&ID) {} + /// We need some target data for accurate signature details that are /// target dependent. So we require target data in our AnalysisUsage. /// @brief Require TargetData from AnalysisUsage. @@ -373,6 +376,7 @@ private: TargetData *TD; ///< Cached TargetData }; +const int SimplifyLibCalls::ID = 0; // Register the pass RegisterPass<SimplifyLibCalls> X("simplify-libcalls", "Simplify well-known library calls"); diff --git a/lib/Transforms/IPO/StripDeadPrototypes.cpp b/lib/Transforms/IPO/StripDeadPrototypes.cpp index 7d03ae68ab..d1467f9b58 100644 --- a/lib/Transforms/IPO/StripDeadPrototypes.cpp +++ b/lib/Transforms/IPO/StripDeadPrototypes.cpp @@ -27,9 +27,12 @@ namespace { /// @brief Pass to remove |