[llvm-commits] [llvm] r69791 - /llvm/trunk/include/llvm/Support/PredIteratorCache.h

Owen Anderson resistor at mac.com
Wed Apr 22 01:46:52 PDT 2009


Author: resistor
Date: Wed Apr 22 03:46:33 2009
New Revision: 69791

URL: http://llvm.org/viewvc/llvm-project?rev=69791&view=rev
Log:
Add caching of predecessor counts as well as predecessors themselves.

Modified:
    llvm/trunk/include/llvm/Support/PredIteratorCache.h

Modified: llvm/trunk/include/llvm/Support/PredIteratorCache.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PredIteratorCache.h?rev=69791&r1=69790&r2=69791&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/PredIteratorCache.h (original)
+++ llvm/trunk/include/llvm/Support/PredIteratorCache.h Wed Apr 22 03:46:33 2009
@@ -27,6 +27,7 @@
   class PredIteratorCache {
     /// BlockToPredsMap - Pointer to null-terminated list.
     DenseMap<BasicBlock*, BasicBlock**> BlockToPredsMap;
+    DenseMap<BasicBlock*, unsigned> BlockToPredCountMap;
 
     /// Memory - This is the space that holds cached preds.
     BumpPtrAllocator Memory;
@@ -44,15 +45,23 @@
 
       SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB));
       PredCache.push_back(0); // null terminator.
+      
+      BlockToPredCountMap[BB] = PredCache.size()-1;
 
       Entry = Memory.Allocate<BasicBlock*>(PredCache.size());
       std::copy(PredCache.begin(), PredCache.end(), Entry);
       return Entry;
     }
+    
+    unsigned GetNumPreds(BasicBlock *BB) {
+      GetPreds(BB);
+      return BlockToPredCountMap[BB];
+    }
 
     /// clear - Remove all information.
     void clear() {
       BlockToPredsMap.clear();
+      BlockToPredCountMap.clear();
       Memory.Reset();
     }
   };





More information about the llvm-commits mailing list