/// updating the dependence of instructions that previously depended on it.
void removeInstruction(Instruction *InstToRemove);
+ /// invalidateCachedPointerInfo - This method is used to invalidate cached
+ /// information about the specified pointer, because it may be too
+ /// conservative in memdep. This is an optional call that can be used when
+ /// the client detects an equivalence between the pointer and some other
+ /// value and replaces the other value with ptr. This can make Ptr available
+ /// in more places that cached info does not necessarily keep.
+ void invalidateCachedPointerInfo(Value *Ptr);
+
private:
MemDepResult getPointerDependencyFrom(Value *Pointer, uint64_t MemSize,
bool isLoad,
NonLocalDepInfo *Cache,
unsigned NumSortedEntries);
-
void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);
/// verifyRemoved - Verify that the specified instruction does not occur
}
+/// invalidateCachedPointerInfo - This method is used to invalidate cached
+/// information about the specified pointer, because it may be too
+/// conservative in memdep. This is an optional call that can be used when
+/// the client detects an equivalence between the pointer and some other
+/// value and replaces the other value with ptr. This can make Ptr available
+/// in more places that cached info does not necessarily keep.
+void MemoryDependenceAnalysis::invalidateCachedPointerInfo(Value *Ptr) {
+ // If Ptr isn't really a pointer, just ignore it.
+ if (!isa<PointerType>(Ptr->getType())) return;
+ // Flush store info for the pointer.
+ RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false));
+ // Flush load info for the pointer.
+ RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true));
+}
+
/// removeInstruction - Remove an instruction from the dependence analysis,
/// updating the dependence of instructions that previously depended on it.
/// This method attempts to keep the cache coherent using the reverse map.
AA->deleteValue(RemInst);
DEBUG(verifyRemoved(RemInst));
}
-
/// verifyRemoved - Verify that the specified instruction does not occur
/// in our internal data structures.
void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
}
PN->replaceAllUsesWith(v);
+ if (isa<PointerType>(v->getType()))
+ MD->invalidateCachedPointerInfo(v);
for (DenseMap<BasicBlock*, Value*>::iterator I = Phis.begin(),
E = Phis.end(); I != E; ++I)
if ((*I)->getParent() == LI->getParent()) {
DEBUG(cerr << "GVN REMOVING NONLOCAL LOAD #1: " << *LI);
LI->replaceAllUsesWith(*I);
+ if (isa<PointerType>((*I)->getType()))
+ MD->invalidateCachedPointerInfo(*I);
toErase.push_back(LI);
NumGVNLoad++;
return true;
// Perform PHI construction.
Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
LI->replaceAllUsesWith(v);
+ if (isa<PointerType>(v->getType()))
+ MD->invalidateCachedPointerInfo(v);
toErase.push_back(LI);
NumGVNLoad++;
return true;
Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
LI->replaceAllUsesWith(v);
v->takeName(LI);
+ if (isa<PointerType>(v->getType()))
+ MD->invalidateCachedPointerInfo(v);
toErase.push_back(LI);
NumPRELoad++;
return true;
// Remove it!
L->replaceAllUsesWith(DepSI->getOperand(0));
+ if (isa<PointerType>(DepSI->getOperand(0)->getType()))
+ MD->invalidateCachedPointerInfo(DepSI->getOperand(0));
toErase.push_back(L);
NumGVNLoad++;
return true;
// Remove it!
L->replaceAllUsesWith(DepLI);
+ if (isa<PointerType>(DepLI->getType()))
+ MD->invalidateCachedPointerInfo(DepLI);
toErase.push_back(L);
NumGVNLoad++;
return true;
PI->second.erase(p);
p->replaceAllUsesWith(constVal);
+ if (isa<PointerType>(constVal->getType()))
+ MD->invalidateCachedPointerInfo(constVal);
toErase.push_back(p);
} else {
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
// Remove it!
VN.erase(I);
I->replaceAllUsesWith(repl);
+ if (isa<PointerType>(repl->getType()))
+ MD->invalidateCachedPointerInfo(repl);
toErase.push_back(I);
return true;
} else {
localAvail[CurrentBlock]->table[valno] = Phi;
CurInst->replaceAllUsesWith(Phi);
+ if (isa<PointerType>(Phi->getType()))
+ MD->invalidateCachedPointerInfo(Phi);
VN.erase(CurInst);
DEBUG(cerr << "GVN PRE removed: " << *CurInst);