Do not use virtual function to identify an analysis pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48520 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2008-03-19 00:48:41 +00:00
parent bebc3642d3
commit c7fe32e840
21 changed files with 39 additions and 111 deletions

View File

@ -300,9 +300,6 @@ public:
// FIXME: Should remove this
virtual bool runOnFunction(Function &F) { return false; }
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual void releaseMemory() { reset(); }
/// getNode - return the (Post)DominatorTree node for the specified basic
@ -667,7 +664,7 @@ public:
static char ID; // Pass ID, replacement for typeid
DominatorTreeBase<BasicBlock>* DT;
DominatorTree() : FunctionPass(intptr_t(&ID)) {
DominatorTree() : FunctionPass(intptr_t(&ID), true) {
DT = new DominatorTreeBase<BasicBlock>(false);
}
@ -694,9 +691,6 @@ public:
return DT->getRootNode();
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@ -843,7 +837,7 @@ protected:
public:
DominanceFrontierBase(intptr_t ID, bool isPostDom)
: FunctionPass(ID), IsPostDominators(isPostDom) {}
: FunctionPass(ID, true), IsPostDominators(isPostDom) {}
/// getRoots - Return the root blocks of the current CFG. This may include
/// multiple blocks if we are computing post dominators. For forward
@ -916,9 +910,6 @@ public:
return Roots[0];
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &) {
Frontiers.clear();
DominatorTree &DT = getAnalysis<DominatorTree>();

View File

@ -25,7 +25,7 @@ class FindUsedTypes : public ModulePass {
std::set<const Type *> UsedTypes;
public:
static char ID; // Pass identification, replacement for typeid
FindUsedTypes() : ModulePass((intptr_t)&ID) {}
FindUsedTypes() : ModulePass((intptr_t)&ID, true) {}
/// getTypes - After the pass has been run, return the set containing all of
/// the types used in the module.
@ -50,10 +50,6 @@ private:
void IncorporateValue(const Value *V);
public:
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
/// run - This incorporates all types used by the specified module
bool runOnModule(Module &M);

View File

@ -47,10 +47,7 @@ class IntervalPartition : public FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid
IntervalPartition() : FunctionPass((intptr_t)&ID), RootInterval(0) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
IntervalPartition() : FunctionPass((intptr_t)&ID, true), RootInterval(0) {}
// run - Calculate the interval partition for this function
virtual bool runOnFunction(Function &F);

View File

@ -879,7 +879,7 @@ class LoopInfo : public FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid
LoopInfo() : FunctionPass(intptr_t(&ID)) {
LoopInfo() : FunctionPass(intptr_t(&ID), true) {
LI = new LoopInfoBase<BasicBlock>();
}
@ -919,9 +919,6 @@ public:
return LI->isLoopHeader(BB);
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
bool isAnalysis() const { return true; }
/// runOnFunction - Calculate the natural loop information.
///
virtual bool runOnFunction(Function &F);

View File

@ -29,7 +29,7 @@ class PMStack;
class LoopPass : public Pass {
public:
explicit LoopPass(intptr_t pid) : Pass(pid) {}
explicit LoopPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
// runOnLoop - This method should be implemented by the subclass to perform
// whatever action is necessary for the specfied Loop.

View File

@ -66,10 +66,7 @@ class MemoryDependenceAnalysis : public FunctionPass {
static Instruction* const Dirty;
static char ID; // Class identification, replacement for typeinfo
MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID, true) {}
/// Pass Implementation stuff. This doesn't do any analysis.
///

View File

@ -25,13 +25,10 @@ struct PostDominatorTree : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
DominatorTreeBase<BasicBlock>* DT;
PostDominatorTree() : FunctionPass((intptr_t)&ID) {
PostDominatorTree() : FunctionPass((intptr_t)&ID, true) {
DT = new DominatorTreeBase<BasicBlock>(true);
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@ -72,9 +69,6 @@ struct PostDominanceFrontier : public DominanceFrontierBase {
PostDominanceFrontier()
: DominanceFrontierBase((intptr_t) &ID, true) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &) {
Frontiers.clear();
PostDominatorTree &DT = getAnalysis<PostDominatorTree>();

View File

@ -192,7 +192,7 @@ namespace llvm {
void *Impl; // ScalarEvolution uses the pimpl pattern
public:
static char ID; // Pass identification, replacement for typeid
ScalarEvolution() : FunctionPass((intptr_t)&ID), Impl(0) {}
ScalarEvolution() : FunctionPass((intptr_t)&ID, true), Impl(0) {}
/// getSCEV - Return a SCEV expression handle for the full generality of the
/// specified expression.
@ -291,9 +291,6 @@ namespace llvm {
/// that no dangling references are left around.
void deleteValueFromRecords(Value *V) const;
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;

View File

@ -31,7 +31,7 @@ class PMStack;
struct CallGraphSCCPass : public Pass {
explicit CallGraphSCCPass(intptr_t pid) : Pass(pid) {}
explicit CallGraphSCCPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
/// doInitialization - This method is called before the SCC's of the program
/// has been processed, allowing the pass to do initialization as necessary.

View File

@ -73,7 +73,7 @@ enum PassManagerType {
class Pass {
AnalysisResolver *Resolver; // Used to resolve analysis
intptr_t PassID;
bool isAnalysisPass; // True if this pass is an analysis pass.
// AnalysisImpls - This keeps track of which passes implement the interfaces
// that are required by the current pass (to implement getAnalysis()).
//
@ -82,10 +82,14 @@ class Pass {
void operator=(const Pass&); // DO NOT IMPLEMENT
Pass(const Pass &); // DO NOT IMPLEMENT
public:
explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {}
explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {}
explicit Pass(intptr_t pid, bool AP = false) : Resolver(0), PassID(pid),
isAnalysisPass(AP) {}
explicit Pass(const void *pid, bool AP = false) : Resolver(0),
PassID((intptr_t)pid),
isAnalysisPass(AP) {}
virtual ~Pass();
bool isAnalysis() const { return isAnalysisPass; }
/// getPassName - Return a nice clean name for a pass. This usually
/// implemented in terms of the name that is registered by one of the
/// Registration templates, but can be overloaded directly.
@ -130,11 +134,6 @@ public:
return Resolver;
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const {
return false;
}
/// getAnalysisUsage - This function should be overriden by passes that need
/// analysis information to do their job. If a pass specifies that it uses a
/// particular analysis result to this function, it can then use the
@ -232,8 +231,8 @@ public:
return PMT_ModulePassManager;
}
explicit ModulePass(intptr_t pid) : Pass(pid) {}
explicit ModulePass(const void *pid) : Pass(pid) {}
explicit ModulePass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
explicit ModulePass(const void *pid, bool AP = false) : Pass(pid, AP) {}
// Force out-of-line virtual method.
virtual ~ModulePass();
};
@ -258,8 +257,9 @@ public:
///
bool runOnModule(Module &M) { return false; }
explicit ImmutablePass(intptr_t pid) : ModulePass(pid) {}
explicit ImmutablePass(const void *pid) : ModulePass(pid) {}
explicit ImmutablePass(intptr_t pid, bool AP = false) : ModulePass(pid, AP) {}
explicit ImmutablePass(const void *pid, bool AP = false)
: ModulePass(pid, AP) {}
// Force out-of-line virtual method.
virtual ~ImmutablePass();
@ -276,8 +276,8 @@ public:
///
class FunctionPass : public Pass {
public:
explicit FunctionPass(intptr_t pid) : Pass(pid) {}
explicit FunctionPass(const void *pid) : Pass(pid) {}
explicit FunctionPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
explicit FunctionPass(const void *pid, bool AP = false) : Pass(pid, AP) {}
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
@ -328,8 +328,8 @@ public:
///
class BasicBlockPass : public Pass {
public:
explicit BasicBlockPass(intptr_t pid) : Pass(pid) {}
explicit BasicBlockPass(const void *pid) : Pass(pid) {}
explicit BasicBlockPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
explicit BasicBlockPass(const void *pid, bool AP = false) : Pass(pid, AP) {}
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.

View File

@ -35,7 +35,7 @@ namespace {
Module *M;
public:
static char ID; // Class identification, replacement for typeinfo
AliasAnalysisCounter() : ModulePass((intptr_t) &ID) {
AliasAnalysisCounter() : ModulePass((intptr_t) &ID, true) {
No = May = Must = 0;
NoMR = JustRef = JustMod = MR = 0;
}
@ -72,9 +72,6 @@ namespace {
}
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
bool runOnModule(Module &M) {
this->M = &M;
InitializeAliasAnalysis(this);

View File

@ -52,7 +52,7 @@ namespace {
public:
static char ID; // Pass identification, replacement for typeid
AAEval() : FunctionPass((intptr_t)&ID) {}
AAEval() : FunctionPass((intptr_t)&ID, true) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AliasAnalysis>();
@ -70,9 +70,6 @@ namespace {
return false;
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
bool runOnFunction(Function &F);
bool doFinalization(Module &M);
};

View File

@ -41,10 +41,7 @@ namespace {
public:
static char ID; // Class identification, replacement for typeinfo
AliasDebugger() : ModulePass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
AliasDebugger() : ModulePass((intptr_t)&ID, true) {}
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class

View File

@ -551,16 +551,13 @@ namespace {
AliasSetTracker *Tracker;
public:
static char ID; // Pass identification, replacement for typeid
AliasSetPrinter() : FunctionPass((intptr_t)&ID) {}
AliasSetPrinter() : FunctionPass((intptr_t)&ID, true) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<AliasAnalysis>();
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &F) {
Tracker = new AliasSetTracker(getAnalysis<AliasAnalysis>());

View File

@ -92,10 +92,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
namespace {
struct VISIBILITY_HIDDEN CFGViewer : public FunctionPass {
static char ID; // Pass identifcation, replacement for typeid
CFGViewer() : FunctionPass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
CFGViewer() : FunctionPass((intptr_t)&ID, true) {}
virtual bool runOnFunction(Function &F) {
F.viewCFG();
@ -115,10 +112,7 @@ namespace {
struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass {
static char ID; // Pass identifcation, replacement for typeid
CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
CFGOnlyViewer() : FunctionPass((intptr_t)&ID, true) {}
virtual bool runOnFunction(Function &F) {
CFGOnly = true;
@ -141,10 +135,7 @@ namespace {
struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
CFGPrinter() : FunctionPass((intptr_t)&ID) {}
explicit CFGPrinter(intptr_t pid) : FunctionPass(pid) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
explicit CFGPrinter(intptr_t pid) : FunctionPass(pid, true) {}
virtual bool runOnFunction(Function &F) {
std::string Filename = "cfg." + F.getName() + ".dot";
@ -173,10 +164,6 @@ namespace {
struct VISIBILITY_HIDDEN CFGOnlyPrinter : public CFGPrinter {
static char ID; // Pass identification, replacement for typeid
CFGOnlyPrinter() : CFGPrinter((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
virtual bool runOnFunction(Function &F) {
bool OldCFGOnly = CFGOnly;
CFGOnly = true;

View File

@ -430,10 +430,7 @@ namespace {
public:
static char ID;
Andersens() : ModulePass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
Andersens() : ModulePass((intptr_t)&ID, true) {}
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);

View File

@ -84,10 +84,7 @@ namespace {
public:
static char ID;
GlobalsModRef() : ModulePass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
GlobalsModRef() : ModulePass((intptr_t)&ID, true) {}
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class

View File

@ -51,12 +51,8 @@ namespace {
abort();
}
public:
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
static char ID; // Pass identification, replacement for typeid
InstCount() : FunctionPass((intptr_t)&ID) {}
InstCount() : FunctionPass((intptr_t)&ID, true) {}
virtual bool runOnFunction(Function &F);

View File

@ -41,10 +41,7 @@ namespace {
// FIXME: This should not be a FunctionPass.
struct VISIBILITY_HIDDEN LoadVN : public FunctionPass, public ValueNumbering {
static char ID; // Class identification, replacement for typeinfo
LoadVN() : FunctionPass((intptr_t)&ID) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
LoadVN() : FunctionPass((intptr_t)&ID, true) {}
/// Pass Implementation stuff. This doesn't do any analysis.
///

View File

@ -34,7 +34,7 @@ namespace {
public:
static char ID; // Class identification, replacement for typeinfo
explicit LoaderPass(const std::string &filename = "")
: ModulePass((intptr_t)&ID), Filename(filename) {
: ModulePass((intptr_t)&ID, true), Filename(filename) {
if (filename.empty()) Filename = ProfileInfoFilename;
}
@ -46,9 +46,6 @@ namespace {
return "Profiling information loader";
}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
/// run - Load the profile information from the specified file.
virtual bool runOnModule(Module &M);
};

View File

@ -430,7 +430,7 @@ void PMTopLevelManager::schedulePass(Pass *P) {
// generate the analysis again. Stale analysis info should not be
// available at this point.
if (P->isAnalysis() && findAnalysisPass(P->getPassInfo()))
return;
return;
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);