random cleanups, no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60218 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-11-28 22:04:47 +00:00
parent b390b1728e
commit 5f589dc77f

View File

@ -510,55 +510,57 @@ void MemoryDependenceAnalysis::dropInstruction(Instruction* drop) {
/// removeInstruction - Remove an instruction from the dependence analysis, /// removeInstruction - Remove an instruction from the dependence analysis,
/// updating the dependence of instructions that previously depended on it. /// updating the dependence of instructions that previously depended on it.
/// This method attempts to keep the cache coherent using the reverse map. /// This method attempts to keep the cache coherent using the reverse map.
void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) { void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
// Figure out the new dep for things that currently depend on rem // Figure out the new dep for things that currently depend on rem
Instruction* newDep = NonLocal; Instruction* newDep = NonLocal;
// Walk through the Non-local dependencies, removing this one as the value
// for any cached queries.
for (DenseMap<BasicBlock*, Value*>::iterator DI = for (DenseMap<BasicBlock*, Value*>::iterator DI =
depGraphNonLocal[rem].begin(), DE = depGraphNonLocal[rem].end(); depGraphNonLocal[RemInst].begin(), DE = depGraphNonLocal[RemInst].end();
DI != DE; ++DI) DI != DE; ++DI)
if (DI->second != None) if (DI->second != None)
reverseDepNonLocal[DI->second].erase(rem); reverseDepNonLocal[DI->second].erase(RemInst);
depMapType::iterator depGraphEntry = depGraphLocal.find(rem);
// If we have a cached local dependence query for this instruction, remove it.
depMapType::iterator depGraphEntry = depGraphLocal.find(RemInst);
if (depGraphEntry != depGraphLocal.end()) { if (depGraphEntry != depGraphLocal.end()) {
reverseDep[depGraphEntry->second.first].erase(rem); Instruction *DepInst = depGraphEntry->second.first;
bool IsConfirmed = depGraphEntry->second.second;
if (depGraphEntry->second.first != NonLocal && reverseDep[DepInst].erase(RemInst);
depGraphEntry->second.first != None &&
depGraphEntry->second.second) { if (DepInst != NonLocal && DepInst != None && IsConfirmed) {
// If we have dep info for rem, set them to it // If we have dep info for rem, set them to it
BasicBlock::iterator RI = depGraphEntry->second.first; BasicBlock::iterator RI = DepInst;
RI++; RI++;
// If RI is rem, then we use rem's immediate successor. // If RI is rem, then we use rem's immediate successor.
if (RI == (BasicBlock::iterator)rem) RI++; if (RI == (BasicBlock::iterator)RemInst) RI++;
newDep = RI; newDep = RI;
} else if ((depGraphEntry->second.first == NonLocal || } else if ((DepInst == NonLocal || DepInst == None) && IsConfirmed) {
depGraphEntry->second.first == None) &&
depGraphEntry->second.second) {
// If we have a confirmed non-local flag, use it // If we have a confirmed non-local flag, use it
newDep = depGraphEntry->second.first; newDep = DepInst;
} else { } else {
// Otherwise, use the immediate successor of rem // Otherwise, use the immediate successor of rem
// NOTE: This is because, when getDependence is called, it will first // NOTE: This is because, when getDependence is called, it will first
// check the immediate predecessor of what is in the cache. // check the immediate predecessor of what is in the cache.
BasicBlock::iterator RI = rem; BasicBlock::iterator RI = RemInst;
RI++; RI++;
newDep = RI; newDep = RI;
} }
depGraphLocal.erase(RemInst);
} else { } else {
// Otherwise, use the immediate successor of rem // Otherwise, use the immediate successor of rem
// NOTE: This is because, when getDependence is called, it will first // NOTE: This is because, when getDependence is called, it will first
// check the immediate predecessor of what is in the cache. // check the immediate predecessor of what is in the cache.
BasicBlock::iterator RI = rem; BasicBlock::iterator RI = RemInst;
RI++; RI++;
newDep = RI; newDep = RI;
} }
SmallPtrSet<Instruction*, 4>& set = reverseDep[rem]; SmallPtrSet<Instruction*, 4>& set = reverseDep[RemInst];
for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end(); for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
I != E; ++I) { I != E; ++I) {
// Insert the new dependencies // Insert the new dependencies
@ -567,27 +569,24 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
newDep == None)); newDep == None));
} }
depGraphLocal.erase(rem); reverseDep.erase(RemInst);
reverseDep.erase(rem);
if (reverseDepNonLocal.count(rem)) { if (reverseDepNonLocal.count(RemInst)) {
SmallPtrSet<Instruction*, 4>& set = reverseDepNonLocal[rem]; SmallPtrSet<Instruction*, 4>& set = reverseDepNonLocal[RemInst];
for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end(); for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
I != E; ++I) I != E; ++I)
for (DenseMap<BasicBlock*, Value*>::iterator DI = for (DenseMap<BasicBlock*, Value*>::iterator DI =
depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end(); depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end();
DI != DE; ++DI) DI != DE; ++DI)
if (DI->second == rem) if (DI->second == RemInst)
DI->second = Dirty; DI->second = Dirty;
} }
reverseDepNonLocal.erase(rem); reverseDepNonLocal.erase(RemInst);
nonLocalDepMapType::iterator I = depGraphNonLocal.find(rem); depGraphNonLocal.erase(RemInst);
if (I != depGraphNonLocal.end())
depGraphNonLocal.erase(I);
getAnalysis<AliasAnalysis>().deleteValue(rem); getAnalysis<AliasAnalysis>().deleteValue(RemInst);
DEBUG(verifyRemoved(rem)); DEBUG(verifyRemoved(RemInst));
} }