forked from OSchip/llvm-project
Convert one of LVI's primary maps to a DenseMap, now that we know are more assured of iterator stability.
llvm-svn: 122273
This commit is contained in:
parent
622220b66d
commit
813a2c45a8
|
@ -287,18 +287,9 @@ raw_ostream &operator<<(raw_ostream &OS, const LVILatticeVal &Val) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
/// LazyValueInfoCache - This is the cache kept by LazyValueInfo which
|
||||
/// maintains information about queries across the clients' queries.
|
||||
class LazyValueInfoCache {
|
||||
public:
|
||||
/// ValueCacheEntryTy - This is all of the cached block information for
|
||||
/// exactly one Value*. The entries are sorted by the BasicBlock* of the
|
||||
/// entries, allowing us to do a lookup with a binary search.
|
||||
typedef std::map<AssertingVH<BasicBlock>, LVILatticeVal> ValueCacheEntryTy;
|
||||
|
||||
private:
|
||||
/// LVIValueHandle - A callback value handle update the cache when
|
||||
/// values are erased.
|
||||
class LazyValueInfoCache;
|
||||
struct LVIValueHandle : public CallbackVH {
|
||||
LazyValueInfoCache *Parent;
|
||||
|
||||
|
@ -311,6 +302,18 @@ namespace {
|
|||
}
|
||||
};
|
||||
|
||||
/// LazyValueInfoCache - This is the cache kept by LazyValueInfo which
|
||||
/// maintains information about queries across the clients' queries.
|
||||
class LazyValueInfoCache {
|
||||
public:
|
||||
/// ValueCacheEntryTy - This is all of the cached block information for
|
||||
/// exactly one Value*. The entries are sorted by the BasicBlock* of the
|
||||
/// entries, allowing us to do a lookup with a binary search.
|
||||
typedef std::map<AssertingVH<BasicBlock>, LVILatticeVal> ValueCacheEntryTy;
|
||||
|
||||
private:
|
||||
friend struct LVIValueHandle;
|
||||
|
||||
/// OverDefinedCacheUpdater - A helper object that ensures that the
|
||||
/// OverDefinedCache is updated whenever solveBlockValue returns.
|
||||
struct OverDefinedCacheUpdater {
|
||||
|
@ -332,7 +335,7 @@ namespace {
|
|||
|
||||
/// ValueCache - This is all of the cached information for all values,
|
||||
/// mapped from Value* to key information.
|
||||
std::map<LVIValueHandle, ValueCacheEntryTy> ValueCache;
|
||||
DenseMap<LVIValueHandle, ValueCacheEntryTy> ValueCache;
|
||||
|
||||
/// OverDefinedCache - This tracks, on a per-block basis, the set of
|
||||
/// values that are over-defined at the end of that block. This is required
|
||||
|
@ -389,7 +392,28 @@ namespace {
|
|||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
void LazyValueInfoCache::LVIValueHandle::deleted() {
|
||||
namespace llvm {
|
||||
template<>
|
||||
struct DenseMapInfo<LVIValueHandle> {
|
||||
typedef DenseMapInfo<Value*> PointerInfo;
|
||||
static inline LVIValueHandle getEmptyKey() {
|
||||
return LVIValueHandle(PointerInfo::getEmptyKey(),
|
||||
static_cast<LazyValueInfoCache*>(0));
|
||||
}
|
||||
static inline LVIValueHandle getTombstoneKey() {
|
||||
return LVIValueHandle(PointerInfo::getTombstoneKey(),
|
||||
static_cast<LazyValueInfoCache*>(0));
|
||||
}
|
||||
static unsigned getHashValue(const LVIValueHandle &Val) {
|
||||
return PointerInfo::getHashValue(Val);
|
||||
}
|
||||
static bool isEqual(const LVIValueHandle &LHS, const LVIValueHandle &RHS) {
|
||||
return LHS == RHS;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void LVIValueHandle::deleted() {
|
||||
for (std::set<std::pair<AssertingVH<BasicBlock>, Value*> >::iterator
|
||||
I = Parent->OverDefinedCache.begin(),
|
||||
E = Parent->OverDefinedCache.end();
|
||||
|
@ -414,7 +438,7 @@ void LazyValueInfoCache::eraseBlock(BasicBlock *BB) {
|
|||
OverDefinedCache.erase(tmp);
|
||||
}
|
||||
|
||||
for (std::map<LVIValueHandle, ValueCacheEntryTy>::iterator
|
||||
for (DenseMap<LVIValueHandle, ValueCacheEntryTy>::iterator
|
||||
I = ValueCache.begin(), E = ValueCache.end(); I != E; ++I)
|
||||
I->second.erase(BB);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue