* Add support for different "PassType's"

* Add new RegisterOpt/RegisterAnalysis templates for registering passes that
  are to show up in opt or analyze
* Register Analyses now
* Change optimizations to use RegisterOpt instead of RegisterPass
* Add support for different "PassType's"
* Add new RegisterOpt/RegisterAnalysis templates for registering passes that
  are to show up in opt or analyze
* Register Analyses now
* Change optimizations to use RegisterOpt instead of RegisterPass
* Remove getPassName implementations from various subclasses


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3112 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-07-26 21:12:44 +00:00
parent 5d549083e2
commit 1e43516dcf
19 changed files with 71 additions and 20 deletions

View File

@ -22,7 +22,6 @@ public:
// //
BasicBlock *getExitNode() const { return ExitNode; } BasicBlock *getExitNode() const { return ExitNode; }
virtual const char *getPassName() const { return "Unify Function Exit Nodes";}
virtual bool runOnFunction(Function &F); virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addProvided(ID); } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addProvided(ID); }
}; };

View File

@ -13,6 +13,8 @@
#include "Support/StatisticReporter.h" #include "Support/StatisticReporter.h"
using std::map; using std::map;
static RegisterAnalysis<BUDataStructures>
X("budatastructure", "Bottom-Up Data Structure Analysis Closure");
AnalysisID BUDataStructures::ID(AnalysisID::create<BUDataStructures>()); AnalysisID BUDataStructures::ID(AnalysisID::create<BUDataStructures>());
// releaseMemory - If the pass pipeline is done with this pass, we can release // releaseMemory - If the pass pipeline is done with this pass, we can release

View File

@ -15,6 +15,8 @@
using std::vector; using std::vector;
static RegisterAnalysis<LocalDataStructures>
X("datastructure", "Local Data Structure Analysis");
AnalysisID LocalDataStructures::ID(AnalysisID::create<LocalDataStructures>()); AnalysisID LocalDataStructures::ID(AnalysisID::create<LocalDataStructures>());
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -40,13 +40,12 @@
#include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/CallGraph.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
#include "llvm/iTerminators.h" #include "llvm/iTerminators.h"
#include "Support/STLExtras.h" #include "Support/STLExtras.h"
#include <algorithm> #include <algorithm>
#include <iostream>
static RegisterAnalysis<CallGraph> X("callgraph", "Call Graph Construction");
AnalysisID CallGraph::ID(AnalysisID::create<CallGraph>()); AnalysisID CallGraph::ID(AnalysisID::create<CallGraph>());

View File

@ -10,6 +10,9 @@
using std::make_pair; using std::make_pair;
static RegisterAnalysis<IntervalPartition>
X("intervals", "Interval Partition Construction");
AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>(), true); AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>(), true);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -15,6 +15,8 @@
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include <iostream> #include <iostream>
static RegisterAnalysis<FunctionLiveVarInfo>
X("livevar", "Live Variable Analysis");
AnalysisID FunctionLiveVarInfo::ID(AnalysisID::create<FunctionLiveVarInfo>()); AnalysisID FunctionLiveVarInfo::ID(AnalysisID::create<FunctionLiveVarInfo>());
LiveVarDebugLevel_t DEBUG_LV; LiveVarDebugLevel_t DEBUG_LV;

View File

@ -13,6 +13,8 @@
#include "Support/DepthFirstIterator.h" #include "Support/DepthFirstIterator.h"
#include <algorithm> #include <algorithm>
static RegisterAnalysis<LoopInfo>
X("loops", "Natural Loop Construction");
AnalysisID LoopInfo::ID(AnalysisID::create<LoopInfo>(), true); AnalysisID LoopInfo::ID(AnalysisID::create<LoopInfo>(), true);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -18,6 +18,11 @@ using std::set;
// DominatorSet Implementation // DominatorSet Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominatorSet>
A("domset", "Dominator Set Construction");
static RegisterAnalysis<PostDominatorSet>
B("postdomset", "Post-Dominator Set Construction");
AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>(), true); AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>(), true);
AnalysisID PostDominatorSet::ID(AnalysisID::create<PostDominatorSet>(), true); AnalysisID PostDominatorSet::ID(AnalysisID::create<PostDominatorSet>(), true);
@ -151,6 +156,11 @@ void PostDominatorSet::getAnalysisUsage(AnalysisUsage &AU) const {
// ImmediateDominators Implementation // ImmediateDominators Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<ImmediateDominators>
C("idom", "Immediate Dominators Construction");
static RegisterAnalysis<ImmediatePostDominators>
D("postidom", "Immediate Post-Dominators Construction");
AnalysisID ImmediateDominators::ID(AnalysisID::create<ImmediateDominators>(), true); AnalysisID ImmediateDominators::ID(AnalysisID::create<ImmediateDominators>(), true);
AnalysisID ImmediatePostDominators::ID(AnalysisID::create<ImmediatePostDominators>(), true); AnalysisID ImmediatePostDominators::ID(AnalysisID::create<ImmediatePostDominators>(), true);
@ -195,6 +205,11 @@ void ImmediateDominatorsBase::calcIDoms(const DominatorSetBase &DS) {
// DominatorTree Implementation // DominatorTree Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominatorTree>
E("domtree", "Dominator Tree Construction");
static RegisterAnalysis<PostDominatorTree>
F("postdomtree", "Post-Dominator Tree Construction");
AnalysisID DominatorTree::ID(AnalysisID::create<DominatorTree>(), true); AnalysisID DominatorTree::ID(AnalysisID::create<DominatorTree>(), true);
AnalysisID PostDominatorTree::ID(AnalysisID::create<PostDominatorTree>(), true); AnalysisID PostDominatorTree::ID(AnalysisID::create<PostDominatorTree>(), true);
@ -307,6 +322,11 @@ void PostDominatorTree::calculate(const PostDominatorSet &DS) {
// DominanceFrontier Implementation // DominanceFrontier Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominanceFrontier>
G("domfrontier", "Dominance Frontier Construction");
static RegisterAnalysis<PostDominanceFrontier>
H("postdomfrontier", "Post-Dominance Frontier Construction");
AnalysisID DominanceFrontier::ID(AnalysisID::create<DominanceFrontier>(), true); AnalysisID DominanceFrontier::ID(AnalysisID::create<DominanceFrontier>(), true);
AnalysisID PostDominanceFrontier::ID(AnalysisID::create<PostDominanceFrontier>(), true); AnalysisID PostDominanceFrontier::ID(AnalysisID::create<PostDominanceFrontier>(), true);

View File

@ -15,6 +15,8 @@
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include <iostream> #include <iostream>
static RegisterAnalysis<FunctionLiveVarInfo>
X("livevar", "Live Variable Analysis");
AnalysisID FunctionLiveVarInfo::ID(AnalysisID::create<FunctionLiveVarInfo>()); AnalysisID FunctionLiveVarInfo::ID(AnalysisID::create<FunctionLiveVarInfo>());
LiveVarDebugLevel_t DEBUG_LV; LiveVarDebugLevel_t DEBUG_LV;

View File

@ -31,8 +31,8 @@ namespace {
} }
}; };
Statistic<> NumMerged("constmerge\t\t- Number of global constants merged"); Statistic<> NumMerged("constmerge\t\t- Number of global constants merged");
RegisterPass<ConstantMerge> X("constmerge", "Merge Duplicate Global Constants"); RegisterOpt<ConstantMerge> X("constmerge","Merge Duplicate Global Constants");
} }
Pass *createConstantMergePass() { return new ConstantMerge(); } Pass *createConstantMergePass() { return new ConstantMerge(); }

View File

@ -30,7 +30,7 @@ namespace {
AU.addRequired(FindUsedTypes::ID); AU.addRequired(FindUsedTypes::ID);
} }
}; };
RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination"); RegisterOpt<DTE> X("deadtypeelim", "Dead Type Elimination");
Statistic<> NumKilled("deadtypeelim\t- Number of unused typenames removed from symtab"); Statistic<> NumKilled("deadtypeelim\t- Number of unused typenames removed from symtab");
} }

View File

@ -32,7 +32,7 @@ namespace {
struct FunctionResolvingPass : public Pass { struct FunctionResolvingPass : public Pass {
bool run(Module &M); bool run(Module &M);
}; };
RegisterPass<FunctionResolvingPass> X("funcresolve", "Resolve Functions"); RegisterOpt<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
} }
Pass *createFunctionResolvingPass() { Pass *createFunctionResolvingPass() {

View File

@ -86,7 +86,7 @@ namespace {
AU.addRequired(CallGraph::ID); AU.addRequired(CallGraph::ID);
} }
}; };
RegisterPass<GlobalDCE> X("globaldce", "Dead Global Elimination"); RegisterOpt<GlobalDCE> X("globaldce", "Dead Global Elimination");
} }
Pass *createGlobalDCEPass() { return new GlobalDCE(); } Pass *createGlobalDCEPass() { return new GlobalDCE(); }

View File

@ -41,7 +41,7 @@ class InternalizePass : public Pass {
} }
}; };
RegisterPass<InternalizePass> X("internalize", "Internalize Functions"); RegisterOpt<InternalizePass> X("internalize", "Internalize Functions");
} // end anonymous namespace } // end anonymous namespace
Pass *createInternalizePass() { Pass *createInternalizePass() {

View File

@ -315,8 +315,8 @@ namespace {
}; };
RegisterPass<PoolAllocate> X("poolalloc", RegisterOpt<PoolAllocate> X("poolalloc",
"Pool allocate disjoint datastructures"); "Pool allocate disjoint datastructures");
} }
// isNotPoolableAlloc - This is a predicate that returns true if the specified // isNotPoolableAlloc - This is a predicate that returns true if the specified

View File

@ -189,10 +189,10 @@ Pass *createSortElementsPass(const TargetData &TD) {
} }
namespace { namespace {
RegisterPass<SwapStructElements> X("swapstructs", RegisterOpt<SwapStructElements> X("swapstructs",
"Swap structure types around", "Swap structure types around",
createSwapElementsPass); createSwapElementsPass);
RegisterPass<SortStructElements> Y("sortstructs", RegisterOpt<SortStructElements> Y("sortstructs",
"Sort structure elements by size", "Sort structure elements by size",
createSortElementsPass); createSortElementsPass);
} }

View File

@ -47,7 +47,7 @@ struct ProfilePaths : public FunctionPass {
} }
}; };
static RegisterPass<ProfilePaths> X("paths", "Profile Paths"); static RegisterOpt<ProfilePaths> X("paths", "Profile Paths");
// createProfilePathsPass - Create a new pass to add path profiling // createProfilePathsPass - Create a new pass to add path profiling
// //

View File

@ -17,7 +17,7 @@ using std::vector;
AnalysisID UnifyFunctionExitNodes::ID(AnalysisID::create<UnifyFunctionExitNodes>()); AnalysisID UnifyFunctionExitNodes::ID(AnalysisID::create<UnifyFunctionExitNodes>());
static RegisterPass<UnifyFunctionExitNodes> static RegisterOpt<UnifyFunctionExitNodes>
X("mergereturn", "Unify function exit nodes"); X("mergereturn", "Unify function exit nodes");
// UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new // UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new

View File

@ -18,6 +18,11 @@ using std::set;
// DominatorSet Implementation // DominatorSet Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominatorSet>
A("domset", "Dominator Set Construction");
static RegisterAnalysis<PostDominatorSet>
B("postdomset", "Post-Dominator Set Construction");
AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>(), true); AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>(), true);
AnalysisID PostDominatorSet::ID(AnalysisID::create<PostDominatorSet>(), true); AnalysisID PostDominatorSet::ID(AnalysisID::create<PostDominatorSet>(), true);
@ -151,6 +156,11 @@ void PostDominatorSet::getAnalysisUsage(AnalysisUsage &AU) const {
// ImmediateDominators Implementation // ImmediateDominators Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<ImmediateDominators>
C("idom", "Immediate Dominators Construction");
static RegisterAnalysis<ImmediatePostDominators>
D("postidom", "Immediate Post-Dominators Construction");
AnalysisID ImmediateDominators::ID(AnalysisID::create<ImmediateDominators>(), true); AnalysisID ImmediateDominators::ID(AnalysisID::create<ImmediateDominators>(), true);
AnalysisID ImmediatePostDominators::ID(AnalysisID::create<ImmediatePostDominators>(), true); AnalysisID ImmediatePostDominators::ID(AnalysisID::create<ImmediatePostDominators>(), true);
@ -195,6 +205,11 @@ void ImmediateDominatorsBase::calcIDoms(const DominatorSetBase &DS) {
// DominatorTree Implementation // DominatorTree Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominatorTree>
E("domtree", "Dominator Tree Construction");
static RegisterAnalysis<PostDominatorTree>
F("postdomtree", "Post-Dominator Tree Construction");
AnalysisID DominatorTree::ID(AnalysisID::create<DominatorTree>(), true); AnalysisID DominatorTree::ID(AnalysisID::create<DominatorTree>(), true);
AnalysisID PostDominatorTree::ID(AnalysisID::create<PostDominatorTree>(), true); AnalysisID PostDominatorTree::ID(AnalysisID::create<PostDominatorTree>(), true);
@ -307,6 +322,11 @@ void PostDominatorTree::calculate(const PostDominatorSet &DS) {
// DominanceFrontier Implementation // DominanceFrontier Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterAnalysis<DominanceFrontier>
G("domfrontier", "Dominance Frontier Construction");
static RegisterAnalysis<PostDominanceFrontier>
H("postdomfrontier", "Post-Dominance Frontier Construction");
AnalysisID DominanceFrontier::ID(AnalysisID::create<DominanceFrontier>(), true); AnalysisID DominanceFrontier::ID(AnalysisID::create<DominanceFrontier>(), true);
AnalysisID PostDominanceFrontier::ID(AnalysisID::create<PostDominanceFrontier>(), true); AnalysisID PostDominanceFrontier::ID(AnalysisID::create<PostDominanceFrontier>(), true);