From 5f589dc77f459d169495ab1e0e03de3740a3b290 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 28 Nov 2008 22:04:47 +0000 Subject: [PATCH] random cleanups, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60218 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/MemoryDependenceAnalysis.cpp | 57 +++++++++++------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index b58fc1dfe6f..d6d59826f69 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -510,55 +510,57 @@ void MemoryDependenceAnalysis::dropInstruction(Instruction* drop) { /// 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. -void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) { +void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) { // Figure out the new dep for things that currently depend on rem Instruction* newDep = NonLocal; + // Walk through the Non-local dependencies, removing this one as the value + // for any cached queries. for (DenseMap::iterator DI = - depGraphNonLocal[rem].begin(), DE = depGraphNonLocal[rem].end(); + depGraphNonLocal[RemInst].begin(), DE = depGraphNonLocal[RemInst].end(); DI != DE; ++DI) if (DI->second != None) - reverseDepNonLocal[DI->second].erase(rem); - - depMapType::iterator depGraphEntry = depGraphLocal.find(rem); + reverseDepNonLocal[DI->second].erase(RemInst); + // If we have a cached local dependence query for this instruction, remove it. + depMapType::iterator depGraphEntry = depGraphLocal.find(RemInst); 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 && - depGraphEntry->second.first != None && - depGraphEntry->second.second) { + reverseDep[DepInst].erase(RemInst); + + if (DepInst != NonLocal && DepInst != None && IsConfirmed) { // If we have dep info for rem, set them to it - BasicBlock::iterator RI = depGraphEntry->second.first; + BasicBlock::iterator RI = DepInst; RI++; // 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; - } else if ((depGraphEntry->second.first == NonLocal || - depGraphEntry->second.first == None) && - depGraphEntry->second.second) { + } else if ((DepInst == NonLocal || DepInst == None) && IsConfirmed) { // If we have a confirmed non-local flag, use it - newDep = depGraphEntry->second.first; + newDep = DepInst; } else { // Otherwise, use the immediate successor of rem // NOTE: This is because, when getDependence is called, it will first // check the immediate predecessor of what is in the cache. - BasicBlock::iterator RI = rem; + BasicBlock::iterator RI = RemInst; RI++; newDep = RI; } + depGraphLocal.erase(RemInst); } else { // Otherwise, use the immediate successor of rem // NOTE: This is because, when getDependence is called, it will first // check the immediate predecessor of what is in the cache. - BasicBlock::iterator RI = rem; + BasicBlock::iterator RI = RemInst; RI++; newDep = RI; } - SmallPtrSet& set = reverseDep[rem]; + SmallPtrSet& set = reverseDep[RemInst]; for (SmallPtrSet::iterator I = set.begin(), E = set.end(); I != E; ++I) { // Insert the new dependencies @@ -567,27 +569,24 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) { newDep == None)); } - depGraphLocal.erase(rem); - reverseDep.erase(rem); + reverseDep.erase(RemInst); - if (reverseDepNonLocal.count(rem)) { - SmallPtrSet& set = reverseDepNonLocal[rem]; + if (reverseDepNonLocal.count(RemInst)) { + SmallPtrSet& set = reverseDepNonLocal[RemInst]; for (SmallPtrSet::iterator I = set.begin(), E = set.end(); I != E; ++I) for (DenseMap::iterator DI = depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end(); DI != DE; ++DI) - if (DI->second == rem) + if (DI->second == RemInst) DI->second = Dirty; } - reverseDepNonLocal.erase(rem); - nonLocalDepMapType::iterator I = depGraphNonLocal.find(rem); - if (I != depGraphNonLocal.end()) - depGraphNonLocal.erase(I); + reverseDepNonLocal.erase(RemInst); + depGraphNonLocal.erase(RemInst); - getAnalysis().deleteValue(rem); + getAnalysis().deleteValue(RemInst); - DEBUG(verifyRemoved(rem)); + DEBUG(verifyRemoved(RemInst)); }