diff options
author | Owen Anderson <resistor@mac.com> | 2009-04-22 08:46:33 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-04-22 08:46:33 +0000 |
commit | ddcb3415cb83a8df3cad5241cbfe46d261946a7b (patch) | |
tree | d20012f7643e2ed8b42aa45cf0c6c5aae6f45dc0 /include/llvm/Support/PredIteratorCache.h | |
parent | 68fbd735f1e0761a3ba16aec4dcb1c1f163f9749 (diff) | |
download | llvm-ddcb3415cb83a8df3cad5241cbfe46d261946a7b.tar.gz llvm-ddcb3415cb83a8df3cad5241cbfe46d261946a7b.tar.bz2 llvm-ddcb3415cb83a8df3cad5241cbfe46d261946a7b.tar.xz |
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
Diffstat (limited to 'include/llvm/Support/PredIteratorCache.h')
-rw-r--r-- | include/llvm/Support/PredIteratorCache.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/Support/PredIteratorCache.h b/include/llvm/Support/PredIteratorCache.h index cef9de0b27..bb66a8ed58 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<BasicBlock*, BasicBlock**> BlockToPredsMap; + DenseMap<BasicBlock*, unsigned> BlockToPredCountMap; /// Memory - This is the space that holds cached preds. BumpPtrAllocator Memory; @@ -44,15 +45,23 @@ namespace llvm { 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(); } }; |