From 5d8925c7c506a54ebdfb0bc93437ec9f602eaaa0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 27 Aug 2006 22:30:17 +0000 Subject: [PATCH] Eliminate RegisterAnalysis. RegisterPass now does all that is necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29921 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassSupport.h | 41 ++++++++----------- lib/Analysis/CFGPrinter.cpp | 6 +-- .../DataStructure/BottomUpClosure.cpp | 2 +- lib/Analysis/DataStructure/CallTargets.cpp | 2 +- .../DataStructure/CompleteBottomUp.cpp | 2 +- .../DataStructure/DataStructureStats.cpp | 2 +- .../DataStructure/EquivClassGraphs.cpp | 2 +- lib/Analysis/DataStructure/GraphChecker.cpp | 2 +- lib/Analysis/DataStructure/Local.cpp | 2 +- lib/Analysis/DataStructure/TopDownClosure.cpp | 2 +- lib/Analysis/IPA/FindUsedTypes.cpp | 2 +- lib/Analysis/InstCount.cpp | 4 +- lib/Analysis/IntervalPartition.cpp | 2 +- lib/Analysis/LoopInfo.cpp | 2 +- lib/Analysis/PostDominators.cpp | 10 ++--- lib/Analysis/ScalarEvolution.cpp | 2 +- lib/CodeGen/LiveIntervalAnalysis.cpp | 2 +- lib/CodeGen/LiveVariables.cpp | 2 +- lib/VMCore/Dominators.cpp | 10 ++--- tools/opt/AnalysisWrappers.cpp | 4 +- tools/opt/GraphPrinters.cpp | 4 +- tools/opt/PrintSCC.cpp | 4 +- 22 files changed, 52 insertions(+), 59 deletions(-) diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index 8d978b35d1b..95702c0cfa5 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -179,24 +179,33 @@ template struct RegisterPass : public RegisterPassBase { // Register Pass using default constructor... - RegisterPass(const char *PassArg, const char *Name) + RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false) : RegisterPassBase(Name, PassArg, typeid(PassName), - callDefaultCtor) {} + callDefaultCtor) { + if (CFGOnly) setOnlyUsesCFG(); + } // Register Pass using default constructor explicitly... RegisterPass(const char *PassArg, const char *Name, - Pass *(*ctor)()) - : RegisterPassBase(Name, PassArg, typeid(PassName), ctor) {} + Pass *(*ctor)(), bool CFGOnly = false) + : RegisterPassBase(Name, PassArg, typeid(PassName), ctor) { + if (CFGOnly) setOnlyUsesCFG(); + } // Register Pass using TargetMachine constructor... RegisterPass(const char *PassArg, const char *Name, - Pass *(*targetctor)(TargetMachine &)) - : RegisterPassBase(Name, PassArg, typeid(PassName), 0, targetctor) {} + Pass *(*targetctor)(TargetMachine &), bool CFGOnly = false) + : RegisterPassBase(Name, PassArg, typeid(PassName), 0, targetctor) { + if (CFGOnly) setOnlyUsesCFG(); + } // Generic constructor version that has an unknown ctor type... template - RegisterPass(const char *PassArg, const char *Name, CtorType *Fn) - : RegisterPassBase(Name, PassArg, typeid(PassName), 0) {} + RegisterPass(const char *PassArg, const char *Name, CtorType *Fn, + bool CFGOnly = false) + : RegisterPassBase(Name, PassArg, typeid(PassName), 0) { + if (CFGOnly) setOnlyUsesCFG(); + } }; /// RegisterOpt - Register something that is to show up in Opt, this is just a @@ -246,22 +255,6 @@ struct RegisterOpt : public RegisterPassBase { } }; -/// RegisterAnalysis - Register something that is to show up in Analysis, this -/// is just a shortcut for specifying RegisterPass... Analyses take a special -/// argument that, when set to true, tells the system that the analysis ONLY -/// depends on the shape of the CFG, so if a transformation preserves the CFG -/// that the analysis is not invalidated. -/// -template -struct RegisterAnalysis : public RegisterPassBase { - RegisterAnalysis(const char *PassArg, const char *Name, - bool CFGOnly = false) - : RegisterPassBase(Name, PassArg, typeid(PassName), - callDefaultCtor) { - if (CFGOnly) setOnlyUsesCFG(); - } -}; - /// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_. /// Analysis groups are used to define an interface (which need not derive from diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index 693c1f6d8c6..a762a8e5f8c 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -109,8 +109,8 @@ namespace { } }; - RegisterAnalysis P1("print-cfg", - "Print CFG of function to 'dot' file"); + RegisterPass P1("print-cfg", + "Print CFG of function to 'dot' file"); struct CFGOnlyPrinter : public CFGPrinter { virtual bool runOnFunction(Function &F) { @@ -127,7 +127,7 @@ namespace { } }; - RegisterAnalysis + RegisterPass P2("print-cfg-only", "Print CFG of function to 'dot' file (with no function bodies)"); } diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index dc7c761194b..d2708b0fb1c 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -37,7 +37,7 @@ namespace { UpdateGlobals("budatastructures-update-from-globals", cl::desc("Update local graph from global graph when processing function")); - RegisterAnalysis + RegisterPass X("budatastructure", "Bottom-up Data Structure Analysis"); } diff --git a/lib/Analysis/DataStructure/CallTargets.cpp b/lib/Analysis/DataStructure/CallTargets.cpp index 30d7d48334d..eb1e28dcc69 100644 --- a/lib/Analysis/DataStructure/CallTargets.cpp +++ b/lib/Analysis/DataStructure/CallTargets.cpp @@ -34,7 +34,7 @@ namespace { Statistic<> CompleteInd("calltarget", "Number of complete indirect calls"); Statistic<> CompleteEmpty("calltarget", "Number of complete empty calls"); - RegisterAnalysis X("calltarget", "Find Call Targets (uses DSA)"); + RegisterPass X("calltarget","Find Call Targets (uses DSA)"); } void CallTargetFinder::findIndTargets(Module &M) diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index 452f0338cb0..ea21a4f0305 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -25,7 +25,7 @@ using namespace llvm; namespace { - RegisterAnalysis + RegisterPass X("cbudatastructure", "'Complete' Bottom-up Data Structure Analysis"); Statistic<> NumCBUInlines("cbudatastructures", "Number of graphs inlined"); } diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index f4aff3013ad..a73fc96e6e3 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -60,7 +60,7 @@ namespace { void print(std::ostream &O, const Module* = 0) const { } }; - static RegisterAnalysis Z("dsstats", "DS Graph Statistics"); + static RegisterPass Z("dsstats", "DS Graph Statistics"); } FunctionPass *llvm::createDataStructureStatsPass() { diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index cc536a7f89c..9126ef98146 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -30,7 +30,7 @@ using namespace llvm; namespace { - RegisterAnalysis X("eqdatastructure", + RegisterPass X("eqdatastructure", "Equivalence-class Bottom-up Data Structure Analysis"); Statistic<> NumEquivBUInlines("equivdatastructures", "Number of graphs inlined"); diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index f42ea7eb08e..50a41f2b9a8 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -74,7 +74,7 @@ namespace { void verify(const DSGraph &G); }; - RegisterAnalysis X("datastructure-gc", "DSA Graph Checking Pass"); + RegisterPass X("datastructure-gc", "DSA Graph Checking Pass"); } FunctionPass *llvm::createDataStructureGraphCheckerPass() { diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index ecf953230dd..c70970ac31d 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -33,7 +33,7 @@ using namespace llvm; -static RegisterAnalysis +static RegisterPass X("datastructure", "Local Data Structure Analysis"); static cl::opt diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 2271fa4c9a5..9fdaac3c348 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -32,7 +32,7 @@ using namespace llvm; #endif namespace { - RegisterAnalysis // Register the pass + RegisterPass // Register the pass Y("tddatastructure", "Top-down Data Structure Analysis"); Statistic<> NumTDInlines("tddatastructures", "Number of graphs inlined"); diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 725cec4c018..d4ea9f9489b 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -21,7 +21,7 @@ #include "llvm/Support/InstIterator.h" using namespace llvm; -static RegisterAnalysis +static RegisterPass X("printusedtypes", "Find Used Types"); // IncorporateType - Incorporate one type and all of its subtypes into the diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index df11fc4895a..72bc2c72387 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -55,8 +55,8 @@ namespace { }; - RegisterAnalysis X("instcount", - "Counts the various types of Instructions"); + RegisterPass X("instcount", + "Counts the various types of Instructions"); } FunctionPass *llvm::createInstCountPass() { return new InstCount(); } diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index a6b85d4b90b..2385a7d2470 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -15,7 +15,7 @@ #include "llvm/Analysis/IntervalIterator.h" using namespace llvm; -static RegisterAnalysis +static RegisterPass X("intervals", "Interval Partition Construction", true); //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index a91c201e0cf..907cf5f4fe6 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -25,7 +25,7 @@ #include using namespace llvm; -static RegisterAnalysis +static RegisterPass X("loops", "Natural Loop Construction", true); //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index e195d7a4c77..ec7f7c75466 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -23,7 +23,7 @@ using namespace llvm; // ImmediatePostDominators Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass D("postidom", "Immediate Post-Dominators Construction", true); unsigned ImmediatePostDominators::DFSPass(BasicBlock *V, InfoRec &VInfo, @@ -145,7 +145,7 @@ bool ImmediatePostDominators::runOnFunction(Function &F) { // PostDominatorSet Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass B("postdomset", "Post-Dominator Set Construction", true); // Postdominator set construction. This converts the specified function to only @@ -212,7 +212,7 @@ bool PostDominatorSet::runOnFunction(Function &F) { // PostDominatorTree Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass F("postdomtree", "Post-Dominator Tree Construction", true); DominatorTreeBase::Node *PostDominatorTree::getNodeForBlock(BasicBlock *BB) { @@ -258,7 +258,7 @@ void PostDominatorTree::calculate(const ImmediatePostDominators &IPD) { // PostETForest Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass G("postetforest", "Post-ET-Forest Construction", true); ETNode *PostETForest::getNodeForBlock(BasicBlock *BB) { @@ -322,7 +322,7 @@ void PostETForest::calculate(const ImmediatePostDominators &ID) { // PostDominanceFrontier Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass H("postdomfrontier", "Post-Dominance Frontier Construction", true); const DominanceFrontier::DomSetType & diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 37c6a44ee84..289297cf3a9 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -80,7 +80,7 @@ using namespace llvm; namespace { - RegisterAnalysis + RegisterPass R("scalar-evolution", "Scalar Evolution Analysis"); Statistic<> diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 7e3bec9381b..4f34881cf0e 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -38,7 +38,7 @@ using namespace llvm; namespace { - RegisterAnalysis X("liveintervals", "Live Interval Analysis"); + RegisterPass X("liveintervals", "Live Interval Analysis"); static Statistic<> numIntervals ("liveintervals", "Number of original intervals"); diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 46a8012ae3a..4f203e983b7 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -38,7 +38,7 @@ #include using namespace llvm; -static RegisterAnalysis X("livevars", "Live Variable Analysis"); +static RegisterPass X("livevars", "Live Variable Analysis"); void LiveVariables::VarInfo::dump() const { std::cerr << "Register Defined by: "; diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index f079acfdb44..9f7e5d9365d 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -44,7 +44,7 @@ using namespace llvm; // //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass C("idom", "Immediate Dominators Construction", true); unsigned ImmediateDominators::DFSPass(BasicBlock *V, InfoRec &VInfo, @@ -243,7 +243,7 @@ void ImmediateDominatorsBase::print(std::ostream &o, const Module* ) const { // DominatorSet Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass B("domset", "Dominator Set Construction", true); // dominates - Return true if A dominates B. This performs the special checks @@ -343,7 +343,7 @@ void DominatorSetBase::print(std::ostream &o, const Module* ) const { // DominatorTree Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass E("domtree", "Dominator Tree Construction", true); // DominatorTreeBase::reset - Free all of the tree node memory. @@ -434,7 +434,7 @@ void DominatorTreeBase::print(std::ostream &o, const Module* ) const { // DominanceFrontier Implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass G("domfrontier", "Dominance Frontier Construction", true); const DominanceFrontier::DomSetType & @@ -813,7 +813,7 @@ ETNode *ETNode::NCA(ETNode *other) { // ETForest implementation //===----------------------------------------------------------------------===// -static RegisterAnalysis +static RegisterPass D("etforest", "ET Forest Construction", true); void ETForestBase::reset() { diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp index b371d50ef33..5c815f2b029 100644 --- a/tools/opt/AnalysisWrappers.cpp +++ b/tools/opt/AnalysisWrappers.cpp @@ -61,7 +61,7 @@ namespace { } }; - RegisterAnalysis + RegisterPass P1("externalfnconstants", "Print external fn callsites passed constants"); struct CallGraphPrinter : public ModulePass { @@ -76,6 +76,6 @@ namespace { } }; - RegisterAnalysis + RegisterPass P2("callgraph", "Print a call graph"); } diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index 8826cd2a777..8ae0a0340ce 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -72,6 +72,6 @@ namespace { } }; - RegisterAnalysis P2("print-callgraph", - "Print Call Graph to 'dot' file"); + RegisterPass P2("print-callgraph", + "Print Call Graph to 'dot' file"); } diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index c0adf5ca034..904442d11f8 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -57,10 +57,10 @@ namespace { } }; - RegisterAnalysis + RegisterPass Y("cfgscc", "Print SCCs of each function CFG"); - RegisterAnalysis + RegisterPass Z("callscc", "Print SCCs of the Call Graph"); } -- 2.34.1