Identify Analysis pass.

Do not run analysis pass again if analysis info is still available.
This fixes PR1441.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48476 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2008-03-18 00:39:19 +00:00
parent b176038f98
commit 1cee94f041
19 changed files with 83 additions and 0 deletions

View File

@ -300,6 +300,9 @@ 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
@ -691,6 +694,9 @@ 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 {
@ -910,6 +916,9 @@ 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

@ -50,6 +50,10 @@ 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

@ -49,6 +49,9 @@ public:
IntervalPartition() : FunctionPass((intptr_t)&ID), RootInterval(0) {}
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
// run - Calculate the interval partition for this function
virtual bool runOnFunction(Function &F);

View File

@ -580,6 +580,9 @@ public:
LoopInfoBase() { }
~LoopInfoBase() { releaseMemory(); }
/// isAnalysis - Return true if this pass is implementing an analysis pass.
virtual bool isAnalysis() const { return true; }
void releaseMemory() {
for (typename std::vector<LoopBase<BlockT>* >::iterator I =
TopLevelLoops.begin(), E = TopLevelLoops.end(); I != E; ++I)

View File

@ -68,6 +68,9 @@ class MemoryDependenceAnalysis : public FunctionPass {
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; }
/// Pass Implementation stuff. This doesn't do any analysis.
///
bool runOnFunction(Function &) {return false; }

View File

@ -29,6 +29,9 @@ struct PostDominatorTree : public FunctionPass {
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 {
@ -69,6 +72,9 @@ 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

@ -291,6 +291,9 @@ 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

@ -130,6 +130,11 @@ 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

View File

@ -72,6 +72,9 @@ 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

@ -70,6 +70,9 @@ 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

@ -43,6 +43,9 @@ namespace {
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; }
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class

View File

@ -558,6 +558,9 @@ namespace {
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

@ -94,6 +94,9 @@ namespace {
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; }
virtual bool runOnFunction(Function &F) {
F.viewCFG();
return false;
@ -114,6 +117,9 @@ namespace {
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; }
virtual bool runOnFunction(Function &F) {
CFGOnly = true;
F.viewCFG();
@ -137,6 +143,9 @@ namespace {
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; }
virtual bool runOnFunction(Function &F) {
std::string Filename = "cfg." + F.getName() + ".dot";
cerr << "Writing '" << Filename << "'...";
@ -164,6 +173,10 @@ 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

@ -432,6 +432,9 @@ namespace {
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; }
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this);
IdentifyObjects(M);

View File

@ -86,6 +86,9 @@ namespace {
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; }
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class
AnalyzeGlobals(M); // find non-addr taken globals

View File

@ -51,6 +51,10 @@ 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) {}

View File

@ -43,6 +43,9 @@ namespace {
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; }
/// Pass Implementation stuff. This doesn't do any analysis.
///
bool runOnFunction(Function &) { return false; }

View File

@ -46,6 +46,9 @@ 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

@ -426,6 +426,12 @@ void PMTopLevelManager::schedulePass(Pass *P) {
// Give pass a chance to prepare the stage.
P->preparePassManager(activeStack);
// If P is an analysis pass and it is available then do not
// generate the analysis again. Stale analysis info should not be
// available at this point.
if (P->isAnalysis() && findAnalysisPass(P->getPassInfo()))
return;
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();