summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-04-22 08:46:33 +0000
committerOwen Anderson <resistor@mac.com>2009-04-22 08:46:33 +0000
commit9ea578ea70a8de81c413a438bf4c39e1f48cb52c (patch)
tree791dc6d6a4f0e514121c0dfd5a82fd4bfbe0885b /llvm
parent725dc2c5bb5294d836b4786288e8c6be78b234ed (diff)
downloadbcm5719-llvm-9ea578ea70a8de81c413a438bf4c39e1f48cb52c.tar.gz
bcm5719-llvm-9ea578ea70a8de81c413a438bf4c39e1f48cb52c.zip
Add caching of predecessor counts as well as predecessors themselves.
llvm-svn: 69791
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/PredIteratorCache.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/PredIteratorCache.h b/llvm/include/llvm/Support/PredIteratorCache.h
index cef9de0b272..bb66a8ed58b 100644
--- a/llvm/include/llvm/Support/PredIteratorCache.h
+++ b/llvm/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();
}
};
OpenPOWER on IntegriCloud