straighten out various memory ownership issues in the callgraph stuff.

This fixes Regression/Other/2002-01-31-CallGraph.ll.

llvm-svn: 32237
This commit is contained in:
Chris Lattner 2006-12-05 19:46:12 +00:00
parent bd4c022c56
commit 1dc35111f1

View File

@ -51,11 +51,9 @@ class BasicCallGraph : public CallGraph, public ModulePass {
public:
BasicCallGraph() : Root(0), ExternalCallingNode(0), CallsExternalNode(0) {}
~BasicCallGraph() { destroy(); }
// runOnModule - Compute the call graph for the specified module.
virtual bool runOnModule(Module &M) {
destroy();
CallGraph::initialize(M);
ExternalCallingNode = getOrInsertFunction(0);
@ -182,8 +180,10 @@ private:
//
// destroy - Release memory for the call graph
virtual void destroy() {
/// CallsExternalNode is not in the function map, delete it explicitly.
delete CallsExternalNode;
CallsExternalNode = 0;
CallGraph::destroy();
}
};
@ -194,7 +194,6 @@ RegisterAnalysisGroup<CallGraph, true> Z(Y);
} //End anonymous namespace
void CallGraph::initialize(Module &M) {
destroy();
Mod = &M;
}