From 6c1a58d6ba3242adf47f76ccbbc10aedd777c4c2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Apr 2002 05:15:33 +0000 Subject: [PATCH] Clean up the ownership model a bit so that nodes actually get deleted more frequently. This still leaks edges quite a bit, but it leaks no nodes (I think). llvm-svn: 2190 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/llvm/lib/CodeGen/InstrSched/SchedGraph.cpp b/llvm/lib/CodeGen/InstrSched/SchedGraph.cpp index daf4a49bb83b..28679bfbdc86 100644 --- a/llvm/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/llvm/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -168,6 +168,9 @@ SchedGraphNode::SchedGraphNode(unsigned int _nodeId, /*dtor*/ SchedGraphNode::~SchedGraphNode() { + // for each node, delete its out-edges + std::for_each(beginOutEdges(), endOutEdges(), + deleter); } void SchedGraphNode::dump(int indent=0) const { @@ -233,16 +236,9 @@ SchedGraph::SchedGraph(const BasicBlock* bb, SchedGraph::~SchedGraph() { for (const_iterator I = begin(); I != end(); ++I) - { - SchedGraphNode *node = I->second; - - // for each node, delete its out-edges - std::for_each(node->beginOutEdges(), node->endOutEdges(), - deleter); - - // then delete the node itself. - delete node; - } + delete I->second; + delete graphRoot; + delete graphLeaf; } @@ -967,8 +963,8 @@ SchedGraphSet::SchedGraphSet(const Function* _function, SchedGraphSet::~SchedGraphSet() { // delete all the graphs - for (const_iterator I = begin(); I != end(); ++I) - delete *I; + for(iterator I = begin(), E = end(); I != E; ++I) + delete *I; // destructor is a friend }