straighten out various memory ownership issues in the callgraph stuff.
authorChris Lattner <sabre@nondot.org>
Tue, 5 Dec 2006 19:46:12 +0000 (19:46 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 5 Dec 2006 19:46:12 +0000 (19:46 +0000)
This fixes Regression/Other/2002-01-31-CallGraph.ll.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32237 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/IPA/CallGraph.cpp

index 61d00f02528450d6689cf6f6b218af95f8c31870..128e11ebd7f28b3b46fa89098f4d466776ba4d80 100644 (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;
 }