Convert analyses over to new Pass framework

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-01-30 23:27:55 +00:00
parent 05ad462d1b
commit facd752d3a
6 changed files with 206 additions and 72 deletions

View File

@ -17,8 +17,7 @@
#define LLVM_ANALYSIS_CALLGRAPH_H
#include "Support/GraphTraits.h"
#include <map>
#include <vector>
#include "llvm/Pass.h"
class Method;
class Module;
@ -62,7 +61,7 @@ private: // Stuff to construct the node, used by CallGraph
};
class CallGraph {
class CallGraph : public Pass {
Module *Mod; // The module this call graph represents
typedef std::map<const Method *, CallGraphNode *> MethodMapTy;
@ -70,8 +69,10 @@ class CallGraph {
CallGraphNode *Root;
public:
CallGraph(Module *TheModule);
~CallGraph();
static AnalysisID ID; // We are an analysis, we must have an ID
CallGraph(AnalysisID AID) : Root(0) { assert(AID == ID); }
~CallGraph() { destroy(); }
typedef MethodMapTy::iterator iterator;
typedef MethodMapTy::const_iterator const_iterator;
@ -111,7 +112,18 @@ public:
return removeMethodFromModule((*this)[Meth]);
}
// run - Compute the call graph for the specified module.
virtual bool run(Module *TheModule);
// getAnalysisUsageInfo - This obviously provides a call graph
virtual void getAnalysisUsageInfo(AnalysisSet &Required,
AnalysisSet &Destroyed,
AnalysisSet &Provided) {
Provided.push_back(ID);
}
private: // Implementation of CallGraph construction
void destroy();
// getNodeFor - Return the node for the specified method or create one if it
// does not already exist.