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/GRConstants.cpp b/Analysis/GRConstants.cpp
index 4ae9077..8b94aaa 100644
--- a/Analysis/GRConstants.cpp
+++ b/Analysis/GRConstants.cpp
@@ -375,23 +375,45 @@
     }      
   }
 
-  // Process the true branch.
-  bool isFeasible = true;
+  // Get the current block counter.
+  GRBlockCounter BC = builder.getBlockCounter();
+    
+  unsigned NumVisited = BC.getNumVisited(builder.getTargetBlock(true)->getBlockID());
   
-  StateTy St = Assume(PrevState, V, true, isFeasible);
+  if (isa<nonlval::ConcreteInt>(V) || 
+      BC.getNumVisited(builder.getTargetBlock(true)->getBlockID()) < 1) {
+    
+    // Process the true branch.
 
-  if (isFeasible)
-    builder.generateNode(St, true);
-  else {
-    builder.markInfeasible(true);
-    isFeasible = true;
+    bool isFeasible = true;
+    
+    StateTy St = Assume(PrevState, V, true, isFeasible);
+
+    if (isFeasible)
+      builder.generateNode(St, true);
+    else
+      builder.markInfeasible(true);
   }
+  else
+    builder.markInfeasible(true);
   
-  // Process the false branch.  
-  St = Assume(PrevState, V, false, isFeasible);
+  NumVisited = BC.getNumVisited(builder.getTargetBlock(true)->getBlockID());
+
   
-  if (isFeasible)
-    builder.generateNode(St, false);
+  if (isa<nonlval::ConcreteInt>(V) || 
+      BC.getNumVisited(builder.getTargetBlock(false)->getBlockID()) < 1) {
+    
+    // Process the false branch.  
+    
+    bool isFeasible = false;
+    
+    StateTy St = Assume(PrevState, V, false, isFeasible);
+    
+    if (isFeasible)
+      builder.generateNode(St, false);
+    else
+      builder.markInfeasible(false);
+  }
   else
     builder.markInfeasible(false);
 }