diff options
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExplodedGraph.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index 0dcbe1ff4a..52892116a2 100644 --- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -45,10 +45,8 @@ void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) { // Cleanup. //===----------------------------------------------------------------------===// -static const unsigned CounterTop = 1000; - ExplodedGraph::ExplodedGraph() - : NumNodes(0), reclaimNodes(false), reclaimCounter(CounterTop) {} + : NumNodes(0), reclaimNodes(false) {} ExplodedGraph::~ExplodedGraph() {} @@ -127,19 +125,12 @@ void ExplodedGraph::collectNode(ExplodedNode *node) { node->~ExplodedNode(); } -void ExplodedGraph::reclaimRecentlyAllocatedNodes() { +void ExplodedGraph::reclaimChangedNodes() { if (ChangedNodes.empty()) return; - // Only periodically relcaim nodes so that we can build up a set of - // nodes that meet the reclamation criteria. Freshly created nodes - // by definition have no successor, and thus cannot be reclaimed (see below). - assert(reclaimCounter > 0); - if (--reclaimCounter != 0) - return; - reclaimCounter = CounterTop; - - for (NodeVector::iterator it = ChangedNodes.begin(), et = ChangedNodes.end(); + for (llvm::DenseSet<ExplodedNode*>::iterator it = + ChangedNodes.begin(), et = ChangedNodes.end(); it != et; ++it) { ExplodedNode *node = *it; if (shouldCollect(node)) @@ -160,6 +151,12 @@ void ExplodedNode::addPredecessor(ExplodedNode *V, ExplodedGraph &G) { assert (!V->isSink()); Preds.addNode(V, G); V->Succs.addNode(this, G); + if (G.reclaimNodes) { + if (Succs.size() == 1 && Preds.size() == 1) + G.ChangedNodes.insert(this); + if (V->Succs.size() == 1 && V->Preds.size() == 1) + G.ChangedNodes.insert(V); + } #ifndef NDEBUG if (NodeAuditor) NodeAuditor->AddEdge(V, this); #endif @@ -256,9 +253,6 @@ ExplodedNode *ExplodedGraph::getNode(const ProgramPoint &L, new (V) NodeTy(L, State, IsSink); - if (reclaimNodes) - ChangedNodes.push_back(V); - // Insert the node into the node set and return it. Nodes.InsertNode(V, InsertPos); ++NumNodes; |