mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-20 10:38:46 +00:00
Add caching of predecessor counts as well as predecessors themselves.
llvm-svn: 69791
This commit is contained in:
parent
b36babc111
commit
1cf271e1d8
@ -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();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user