At this revision, test/Analysis/taint-tester.c is failing nondeterministically. I've not narrowed this down to a specific change yet.<div><br><div class="gmail_quote">On Thu, Feb 16, 2012 at 12:19 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kremenek<br>
Date: Thu Feb 16 14:19:30 2012<br>
New Revision: 150720<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=150720&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=150720&view=rev</a><br>
Log:<br>
Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h<br>
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp<br>
cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp<br>
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>
<br>
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=150720&r1=150719&r2=150720&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=150720&r1=150719&r2=150720&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original)<br>
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Thu Feb 16 14:19:30 2012<br>
@@ -25,6 +25,7 @@<br>
#include "llvm/ADT/SmallVector.h"<br>
#include "llvm/ADT/FoldingSet.h"<br>
#include "llvm/ADT/SmallPtrSet.h"<br>
+#include "llvm/ADT/DenseSet.h"<br>
#include "llvm/Support/Allocator.h"<br>
#include "llvm/ADT/OwningPtr.h"<br>
#include "llvm/ADT/GraphTraits.h"<br>
@@ -240,6 +241,7 @@<br>
class ExplodedGraph {<br>
protected:<br>
friend class CoreEngine;<br>
+ friend class ExplodedNode;<br>
<br>
// Type definitions.<br>
typedef std::vector<ExplodedNode *> NodeVector;<br>
@@ -265,16 +267,13 @@<br>
unsigned NumNodes;<br>
<br>
/// A list of recently allocated nodes that can potentially be recycled.<br>
- NodeVector ChangedNodes;<br>
+ llvm::DenseSet<ExplodedNode*> ChangedNodes;<br>
<br>
/// A list of nodes that can be reused.<br>
NodeVector FreeNodes;<br>
<br>
/// A flag that indicates whether nodes should be recycled.<br>
bool reclaimNodes;<br>
-<br>
- /// Counter to determine when to reclaim nodes.<br>
- unsigned reclaimCounter;<br>
<br>
public:<br>
<br>
@@ -361,12 +360,12 @@<br>
llvm::DenseMap<const void*, const void*> *InverseMap) const;<br>
<br>
/// Enable tracking of recently allocated nodes for potential reclamation<br>
- /// when calling reclaimRecentlyAllocatedNodes().<br>
+ /// when calling reclaimChangedNodes().<br>
void enableNodeReclamation() { reclaimNodes = true; }<br>
<br>
/// Reclaim "uninteresting" nodes created since the last time this method<br>
/// was called.<br>
- void reclaimRecentlyAllocatedNodes();<br>
+ void reclaimChangedNodes();<br>
<br>
private:<br>
bool shouldCollect(const ExplodedNode *node);<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=150720&r1=150719&r2=150720&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=150720&r1=150719&r2=150720&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Thu Feb 16 14:19:30 2012<br>
@@ -192,6 +192,7 @@<br>
--Steps;<br>
}<br>
<br>
+ getGraph().reclaimChangedNodes();<br>
const WorkListUnit& WU = WList->dequeue();<br>
<br>
// Set the current block counter.<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=150720&r1=150719&r2=150720&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=150720&r1=150719&r2=150720&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Thu Feb 16 14:19:30 2012<br>
@@ -45,10 +45,8 @@<br>
// Cleanup.<br>
//===----------------------------------------------------------------------===//<br>
<br>
-static const unsigned CounterTop = 1000;<br>
-<br>
ExplodedGraph::ExplodedGraph()<br>
- : NumNodes(0), reclaimNodes(false), reclaimCounter(CounterTop) {}<br>
+ : NumNodes(0), reclaimNodes(false) {}<br>
<br>
ExplodedGraph::~ExplodedGraph() {}<br>
<br>
@@ -127,19 +125,12 @@<br>
node->~ExplodedNode();<br>
}<br>
<br>
-void ExplodedGraph::reclaimRecentlyAllocatedNodes() {<br>
+void ExplodedGraph::reclaimChangedNodes() {<br>
if (ChangedNodes.empty())<br>
return;<br>
<br>
- // Only periodically relcaim nodes so that we can build up a set of<br>
- // nodes that meet the reclamation criteria. Freshly created nodes<br>
- // by definition have no successor, and thus cannot be reclaimed (see below).<br>
- assert(reclaimCounter > 0);<br>
- if (--reclaimCounter != 0)<br>
- return;<br>
- reclaimCounter = CounterTop;<br>
-<br>
- for (NodeVector::iterator it = ChangedNodes.begin(), et = ChangedNodes.end();<br>
+ for (llvm::DenseSet<ExplodedNode*>::iterator it =<br>
+ ChangedNodes.begin(), et = ChangedNodes.end();<br>
it != et; ++it) {<br>
ExplodedNode *node = *it;<br>
if (shouldCollect(node))<br>
@@ -160,6 +151,12 @@<br>
assert (!V->isSink());<br>
Preds.addNode(V, G);<br>
V->Succs.addNode(this, G);<br>
+ if (G.reclaimNodes) {<br>
+ if (Succs.size() == 1 && Preds.size() == 1)<br>
+ G.ChangedNodes.insert(this);<br>
+ if (V->Succs.size() == 1 && V->Preds.size() == 1)<br>
+ G.ChangedNodes.insert(V);<br>
+ }<br>
#ifndef NDEBUG<br>
if (NodeAuditor) NodeAuditor->AddEdge(V, this);<br>
#endif<br>
@@ -256,9 +253,6 @@<br>
<br>
new (V) NodeTy(L, State, IsSink);<br>
<br>
- if (reclaimNodes)<br>
- ChangedNodes.push_back(V);<br>
-<br>
// Insert the node into the node set and return it.<br>
Nodes.InsertNode(V, InsertPos);<br>
++NumNodes;<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=150720&r1=150719&r2=150720&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=150720&r1=150719&r2=150720&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Feb 16 14:19:30 2012<br>
@@ -238,10 +238,7 @@<br>
}<br>
<br>
void ExprEngine::ProcessStmt(const CFGStmt S,<br>
- ExplodedNode *Pred) {<br>
- // Reclaim any unnecessary nodes in the ExplodedGraph.<br>
- G.reclaimRecentlyAllocatedNodes();<br>
-<br>
+ ExplodedNode *Pred) {<br>
currentStmt = S.getStmt();<br>
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),<br>
currentStmt->getLocStart(),<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>