+/// dropInstruction - Remove an instruction from the analysis, making
+/// absolutely conservative assumptions when updating the cache. This is
+/// useful, for example when an instruction is changed rather than removed.
+void MemoryDependenceAnalysis::dropInstruction(Instruction* drop) {
+ depMapType::iterator depGraphEntry = depGraphLocal.find(drop);
+ if (depGraphEntry != depGraphLocal.end())
+ reverseDep[depGraphEntry->second.first].erase(drop);
+
+ // Drop dependency information for things that depended on this instr
+ SmallPtrSet<Instruction*, 4>& set = reverseDep[drop];
+ for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
+ I != E; ++I)
+ depGraphLocal.erase(*I);
+
+ depGraphLocal.erase(drop);
+ reverseDep.erase(drop);
+
+ for (DenseMap<BasicBlock*, Value*>::iterator DI =
+ depGraphNonLocal[drop].begin(), DE = depGraphNonLocal[drop].end();
+ DI != DE; ++DI)
+ if (DI->second != None)
+ reverseDepNonLocal[DI->second].erase(drop);
+
+ if (reverseDepNonLocal.count(drop)) {
+ SmallPtrSet<Instruction*, 4>& set = reverseDepNonLocal[drop];
+ for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
+ I != E; ++I)
+ for (DenseMap<BasicBlock*, Value*>::iterator DI =
+ depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end();
+ DI != DE; ++DI)
+ if (DI->second == drop)
+ DI->second = Dirty;
+ }
+
+ reverseDepNonLocal.erase(drop);
+ nonLocalDepMapType::iterator I = depGraphNonLocal.find(drop);
+ if (I != depGraphNonLocal.end())
+ depGraphNonLocal.erase(I);
+}
+