aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-02-16 20:48:04 +0000
committerTed Kremenek <kremenek@apple.com>2012-02-16 20:48:04 +0000
commit2ac58b7c09938bb28c51c7cd2deada609b75f94c (patch)
treed97438f7e5674c60cb1832f12944b419120150cc /lib/StaticAnalyzer/Core/ExplodedGraph.cpp
parentb9c64d84ea3edd5e2fffb0a2e85ca1308be4f429 (diff)
Revert "Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change."
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExplodedGraph.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/ExplodedGraph.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
index 52892116a2..0dcbe1ff4a 100644
--- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -45,8 +45,10 @@ void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) {
// Cleanup.
//===----------------------------------------------------------------------===//
+static const unsigned CounterTop = 1000;
+
ExplodedGraph::ExplodedGraph()
- : NumNodes(0), reclaimNodes(false) {}
+ : NumNodes(0), reclaimNodes(false), reclaimCounter(CounterTop) {}
ExplodedGraph::~ExplodedGraph() {}
@@ -125,12 +127,19 @@ void ExplodedGraph::collectNode(ExplodedNode *node) {
node->~ExplodedNode();
}
-void ExplodedGraph::reclaimChangedNodes() {
+void ExplodedGraph::reclaimRecentlyAllocatedNodes() {
if (ChangedNodes.empty())
return;
- for (llvm::DenseSet<ExplodedNode*>::iterator it =
- ChangedNodes.begin(), et = ChangedNodes.end();
+ // 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();
it != et; ++it) {
ExplodedNode *node = *it;
if (shouldCollect(node))
@@ -151,12 +160,6 @@ 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
@@ -253,6 +256,9 @@ 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;