From: Owen Anderson Date: Wed, 22 Apr 2009 08:46:33 +0000 (+0000) Subject: Add caching of predecessor counts as well as predecessors themselves. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ddcb3415cb83a8df3cad5241cbfe46d261946a7b;p=oota-llvm.git Add caching of predecessor counts as well as predecessors themselves. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69791 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/PredIteratorCache.h b/include/llvm/Support/PredIteratorCache.h index cef9de0b272..bb66a8ed58b 100644 --- a/include/llvm/Support/PredIteratorCache.h +++ b/include/llvm/Support/PredIteratorCache.h @@ -27,6 +27,7 @@ namespace llvm { class PredIteratorCache { /// BlockToPredsMap - Pointer to null-terminated list. DenseMap BlockToPredsMap; + DenseMap BlockToPredCountMap; /// Memory - This is the space that holds cached preds. BumpPtrAllocator Memory; @@ -44,15 +45,23 @@ namespace llvm { SmallVector PredCache(pred_begin(BB), pred_end(BB)); PredCache.push_back(0); // null terminator. + + BlockToPredCountMap[BB] = PredCache.size()-1; Entry = Memory.Allocate(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(); } };