Added GRBlockCounter class, which tracks the number of times blocks
have been visited in a path. Added GRBlockCounter as an item to be
enqueued to the worklist.
Modified "ProcessBranch" in GRConstants to prune branches with symbolic
conditions that have been already taken.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47010 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GREngine.cpp b/Analysis/GREngine.cpp
index e3b238a..9858f24 100644
--- a/Analysis/GREngine.cpp
+++ b/Analysis/GREngine.cpp
@@ -71,6 +71,9 @@
// starting location in the function.
BlockEdge StartLoc(getCFG(), Entry, Succ);
+ // Set the current block counter to being empty.
+ WList->setBlockCounter(BCounterFactory.GetEmptyCounter());
+
// Generate the root.
GenerateNode(StartLoc, getInitialState());
}
@@ -78,6 +81,11 @@
while (Steps && WList->hasWork()) {
--Steps;
const GRWorkListUnit& WU = WList->Dequeue();
+
+ // Set the current block counter.
+ WList->setBlockCounter(WU.getBlockCounter());
+
+ // Retrieve the node.
ExplodedNodeImpl* Node = WU.getNode();
// Dispatch on the location type.
@@ -138,6 +146,12 @@
void GREngineImpl::HandleBlockEntrance(const BlockEntrance& L,
ExplodedNodeImpl* Pred) {
+ // Increment the block counter.
+ GRBlockCounter Counter = WList->getBlockCounter();
+ Counter = BCounterFactory.IncrementCount(Counter, L.getBlock()->getBlockID());
+ WList->setBlockCounter(Counter);
+
+ // Process the entrance of the block.
if (Stmt* S = L.getFirstStmt()) {
GRStmtNodeBuilderImpl Builder(L.getBlock(), 0, Pred, this);
ProcessStmt(S, Builder);
@@ -196,7 +210,7 @@
ExplodedNodeImpl* Pred) {
assert (B->succ_size() == 2);
- GRBranchNodeBuilderImpl Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
+ GRBranchNodeBuilderImpl Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
Pred, this);
ProcessBranch(Cond, Term, Builder);
@@ -244,7 +258,7 @@
}
// Only add 'Node' to the worklist if it was freshly generated.
- if (IsNew) WList->Enqueue(GRWorkListUnit(Node));
+ if (IsNew) WList->Enqueue(Node);
}
GRStmtNodeBuilderImpl::GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx,
@@ -325,5 +339,5 @@
if (!GeneratedFalse) generateNodeImpl(Pred->State, false);
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
- if (!(*I)->isSink()) Eng.WList->Enqueue(GRWorkListUnit(*I));
+ if (!(*I)->isSink()) Eng.WList->Enqueue(*I);
}