mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-06 03:38:34 +00:00
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
This commit is contained in:
parent
68fbd735f1
commit
ddcb3415cb
@ -27,6 +27,7 @@ namespace llvm {
|
|||||||
class PredIteratorCache {
|
class PredIteratorCache {
|
||||||
/// BlockToPredsMap - Pointer to null-terminated list.
|
/// BlockToPredsMap - Pointer to null-terminated list.
|
||||||
DenseMap<BasicBlock*, BasicBlock**> BlockToPredsMap;
|
DenseMap<BasicBlock*, BasicBlock**> BlockToPredsMap;
|
||||||
|
DenseMap<BasicBlock*, unsigned> BlockToPredCountMap;
|
||||||
|
|
||||||
/// Memory - This is the space that holds cached preds.
|
/// Memory - This is the space that holds cached preds.
|
||||||
BumpPtrAllocator Memory;
|
BumpPtrAllocator Memory;
|
||||||
@ -44,15 +45,23 @@ namespace llvm {
|
|||||||
|
|
||||||
SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB));
|
SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB));
|
||||||
PredCache.push_back(0); // null terminator.
|
PredCache.push_back(0); // null terminator.
|
||||||
|
|
||||||
|
BlockToPredCountMap[BB] = PredCache.size()-1;
|
||||||
|
|
||||||
Entry = Memory.Allocate<BasicBlock*>(PredCache.size());
|
Entry = Memory.Allocate<BasicBlock*>(PredCache.size());
|
||||||
std::copy(PredCache.begin(), PredCache.end(), Entry);
|
std::copy(PredCache.begin(), PredCache.end(), Entry);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned GetNumPreds(BasicBlock *BB) {
|
||||||
|
GetPreds(BB);
|
||||||
|
return BlockToPredCountMap[BB];
|
||||||
|
}
|
||||||
|
|
||||||
/// clear - Remove all information.
|
/// clear - Remove all information.
|
||||||
void clear() {
|
void clear() {
|
||||||
BlockToPredsMap.clear();
|
BlockToPredsMap.clear();
|
||||||
|
BlockToPredCountMap.clear();
|
||||||
Memory.Reset();
|
Memory.Reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user