now that you can put a PointerIntPair in a SmallPtrSet, remove some

hackish workarounds from memdep


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-03-29 00:24:04 +00:00
parent 4d4177b9b3
commit 6a0dcc1077
2 changed files with 16 additions and 19 deletions

View File

@ -171,9 +171,8 @@ namespace llvm {
CachedNonLocalPointerInfo NonLocalPointerDeps; CachedNonLocalPointerInfo NonLocalPointerDeps;
// A map from instructions to their non-local pointer dependencies. // A map from instructions to their non-local pointer dependencies.
// The elements of the SmallPtrSet are ValueIsLoadPair's.
typedef DenseMap<Instruction*, typedef DenseMap<Instruction*,
SmallPtrSet<void*, 4> > ReverseNonLocalPtrDepTy; SmallPtrSet<ValueIsLoadPair, 4> > ReverseNonLocalPtrDepTy;
ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps; ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;

View File

@ -86,9 +86,9 @@ bool MemoryDependenceAnalysis::runOnFunction(Function &) {
/// 'Inst's set in ReverseMap. If the set becomes empty, remove Inst's entry. /// 'Inst's set in ReverseMap. If the set becomes empty, remove Inst's entry.
template <typename KeyTy> template <typename KeyTy>
static void RemoveFromReverseMap(DenseMap<Instruction*, static void RemoveFromReverseMap(DenseMap<Instruction*,
SmallPtrSet<KeyTy*, 4> > &ReverseMap, SmallPtrSet<KeyTy, 4> > &ReverseMap,
Instruction *Inst, KeyTy *Val) { Instruction *Inst, KeyTy Val) {
typename DenseMap<Instruction*, SmallPtrSet<KeyTy*, 4> >::iterator typename DenseMap<Instruction*, SmallPtrSet<KeyTy, 4> >::iterator
InstIt = ReverseMap.find(Inst); InstIt = ReverseMap.find(Inst);
assert(InstIt != ReverseMap.end() && "Reverse map out of sync?"); assert(InstIt != ReverseMap.end() && "Reverse map out of sync?");
bool Found = InstIt->second.erase(Val); bool Found = InstIt->second.erase(Val);
@ -560,8 +560,7 @@ GetNonLocalInfoForBlock(Value *Pointer, uint64_t PointeeSize,
// Eliminating the dirty entry from 'Cache', so update the reverse info. // Eliminating the dirty entry from 'Cache', so update the reverse info.
ValueIsLoadPair CacheKey(Pointer, isLoad); ValueIsLoadPair CacheKey(Pointer, isLoad);
RemoveFromReverseMap(ReverseNonLocalPtrDeps, ScanPos, RemoveFromReverseMap(ReverseNonLocalPtrDeps, ScanPos, CacheKey);
CacheKey.getOpaqueValue());
} else { } else {
++NumUncacheNonLocalPtr; ++NumUncacheNonLocalPtr;
} }
@ -588,7 +587,7 @@ GetNonLocalInfoForBlock(Value *Pointer, uint64_t PointeeSize,
Instruction *Inst = Dep.getInst(); Instruction *Inst = Dep.getInst();
assert(Inst && "Didn't depend on anything?"); assert(Inst && "Didn't depend on anything?");
ValueIsLoadPair CacheKey(Pointer, isLoad); ValueIsLoadPair CacheKey(Pointer, isLoad);
ReverseNonLocalPtrDeps[Inst].insert(CacheKey.getOpaqueValue()); ReverseNonLocalPtrDeps[Inst].insert(CacheKey);
return Dep; return Dep;
} }
@ -827,7 +826,7 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
assert(I->second.isNonLocal() && assert(I->second.isNonLocal() &&
"Should only be here with transparent block"); "Should only be here with transparent block");
I->second = MemDepResult::getClobber(BB->begin()); I->second = MemDepResult::getClobber(BB->begin());
ReverseNonLocalPtrDeps[BB->begin()].insert(CacheKey.getOpaqueValue()); ReverseNonLocalPtrDeps[BB->begin()].insert(CacheKey);
Result.push_back(*I); Result.push_back(*I);
break; break;
} }
@ -883,7 +882,7 @@ RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P) {
assert(Target->getParent() == PInfo[i].first); assert(Target->getParent() == PInfo[i].first);
// Eliminating the dirty entry from 'Cache', so update the reverse info. // Eliminating the dirty entry from 'Cache', so update the reverse info.
RemoveFromReverseMap(ReverseNonLocalPtrDeps, Target, P.getOpaqueValue()); RemoveFromReverseMap(ReverseNonLocalPtrDeps, Target, P);
} }
// Remove P from NonLocalPointerDeps (which deletes NonLocalDepInfo). // Remove P from NonLocalPointerDeps (which deletes NonLocalDepInfo).
@ -1030,13 +1029,12 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
ReverseNonLocalPtrDepTy::iterator ReversePtrDepIt = ReverseNonLocalPtrDepTy::iterator ReversePtrDepIt =
ReverseNonLocalPtrDeps.find(RemInst); ReverseNonLocalPtrDeps.find(RemInst);
if (ReversePtrDepIt != ReverseNonLocalPtrDeps.end()) { if (ReversePtrDepIt != ReverseNonLocalPtrDeps.end()) {
SmallPtrSet<void*, 4> &Set = ReversePtrDepIt->second; SmallPtrSet<ValueIsLoadPair, 4> &Set = ReversePtrDepIt->second;
SmallVector<std::pair<Instruction*, ValueIsLoadPair>,8> ReversePtrDepsToAdd; SmallVector<std::pair<Instruction*, ValueIsLoadPair>,8> ReversePtrDepsToAdd;
for (SmallPtrSet<void*, 4>::iterator I = Set.begin(), E = Set.end(); for (SmallPtrSet<ValueIsLoadPair, 4>::iterator I = Set.begin(),
I != E; ++I) { E = Set.end(); I != E; ++I) {
ValueIsLoadPair P; ValueIsLoadPair P = *I;
P.setFromOpaqueValue(*I);
assert(P.getPointer() != RemInst && assert(P.getPointer() != RemInst &&
"Already removed NonLocalPointerDeps info for RemInst"); "Already removed NonLocalPointerDeps info for RemInst");
@ -1066,7 +1064,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
while (!ReversePtrDepsToAdd.empty()) { while (!ReversePtrDepsToAdd.empty()) {
ReverseNonLocalPtrDeps[ReversePtrDepsToAdd.back().first] ReverseNonLocalPtrDeps[ReversePtrDepsToAdd.back().first]
.insert(ReversePtrDepsToAdd.back().second.getOpaqueValue()); .insert(ReversePtrDepsToAdd.back().second);
ReversePtrDepsToAdd.pop_back(); ReversePtrDepsToAdd.pop_back();
} }
} }
@ -1126,10 +1124,10 @@ void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
E = ReverseNonLocalPtrDeps.end(); I != E; ++I) { E = ReverseNonLocalPtrDeps.end(); I != E; ++I) {
assert(I->first != D && "Inst occurs in rev NLPD map"); assert(I->first != D && "Inst occurs in rev NLPD map");
for (SmallPtrSet<void*, 4>::const_iterator II = I->second.begin(), for (SmallPtrSet<ValueIsLoadPair, 4>::const_iterator II = I->second.begin(),
E = I->second.end(); II != E; ++II) E = I->second.end(); II != E; ++II)
assert(*II != ValueIsLoadPair(D, false).getOpaqueValue() && assert(*II != ValueIsLoadPair(D, false) &&
*II != ValueIsLoadPair(D, true).getOpaqueValue() && *II != ValueIsLoadPair(D, true) &&
"Inst occurs in ReverseNonLocalPtrDeps map"); "Inst occurs in ReverseNonLocalPtrDeps map");
} }