9c269053c129f36b1fadb31796334256c823b2e2
[oota-llvm.git] / lib / Analysis / MemoryDependenceAnalysis.cpp
1 //===- MemoryDependenceAnalysis.cpp - Mem Deps Implementation  --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements an analysis that determines, for a given memory
11 // operation, what preceding memory operations it depends on.  It builds on 
12 // alias analysis information, and tries to provide a lazy, caching interface to
13 // a common kind of alias information query.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #define DEBUG_TYPE "memdep"
18 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
19 #include "llvm/Constants.h"
20 #include "llvm/Instructions.h"
21 #include "llvm/Function.h"
22 #include "llvm/Analysis/AliasAnalysis.h"
23 #include "llvm/ADT/Statistic.h"
24 #include "llvm/ADT/STLExtras.h"
25 #include "llvm/Support/CFG.h"
26 #include "llvm/Support/CommandLine.h"
27 #include "llvm/Support/Debug.h"
28 #include "llvm/Target/TargetData.h"
29
30 using namespace llvm;
31
32 // Control the calculation of non-local dependencies by only examining the
33 // predecessors if the basic block has less than X amount (50 by default).
34 static cl::opt<int> 
35 PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
36           cl::desc("Control the calculation of non-local"
37                    "dependencies (default = 50)"));           
38
39 STATISTIC(NumCacheNonlocal, "Number of cached non-local responses");
40 STATISTIC(NumUncacheNonlocal, "Number of uncached non-local responses");
41
42 char MemoryDependenceAnalysis::ID = 0;
43   
44 Instruction* const MemoryDependenceAnalysis::NonLocal = (Instruction*)-3;
45 Instruction* const MemoryDependenceAnalysis::None = (Instruction*)-4;
46 Instruction* const MemoryDependenceAnalysis::Dirty = (Instruction*)-5;
47   
48 // Register this pass...
49 static RegisterPass<MemoryDependenceAnalysis> X("memdep",
50                                      "Memory Dependence Analysis", false, true);
51
52 /// verifyRemoved - Verify that the specified instruction does not occur
53 /// in our internal data structures.
54 void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
55   for (depMapType::const_iterator I = depGraphLocal.begin(),
56        E = depGraphLocal.end(); I != E; ++I) {
57     assert(I->first != D && "Inst occurs in data structures");
58     assert(I->second.first != D && "Inst occurs in data structures");
59   }
60
61   for (nonLocalDepMapType::const_iterator I = depGraphNonLocal.begin(),
62        E = depGraphNonLocal.end(); I != E; ++I) {
63     assert(I->first != D && "Inst occurs in data structures");
64     for (DenseMap<BasicBlock*, Value*>::iterator II = I->second.begin(),
65          EE = I->second.end(); II  != EE; ++II)
66       assert(II->second != D && "Inst occurs in data structures");
67   }
68
69   for (reverseDepMapType::const_iterator I = reverseDep.begin(),
70        E = reverseDep.end(); I != E; ++I)
71     for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
72          EE = I->second.end(); II != EE; ++II)
73       assert(*II != D && "Inst occurs in data structures");
74
75   for (reverseDepMapType::const_iterator I = reverseDepNonLocal.begin(),
76        E = reverseDepNonLocal.end();
77        I != E; ++I)
78     for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
79          EE = I->second.end(); II != EE; ++II)
80       assert(*II != D && "Inst occurs in data structures");
81 }
82
83 /// getAnalysisUsage - Does not modify anything.  It uses Alias Analysis.
84 ///
85 void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
86   AU.setPreservesAll();
87   AU.addRequiredTransitive<AliasAnalysis>();
88   AU.addRequiredTransitive<TargetData>();
89 }
90
91 /// getCallSiteDependency - Private helper for finding the local dependencies
92 /// of a call site.
93 Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
94                                                              Instruction* start,
95                                                             BasicBlock* block) {
96   
97   std::pair<Instruction*, bool>& cachedResult =
98                                               depGraphLocal[C.getInstruction()];
99   AliasAnalysis& AA = getAnalysis<AliasAnalysis>();
100   TargetData& TD = getAnalysis<TargetData>();
101   BasicBlock::iterator blockBegin = C.getInstruction()->getParent()->begin();
102   BasicBlock::iterator QI = C.getInstruction();
103   
104   // If the starting point was specified, use it
105   if (start) {
106     QI = start;
107     blockBegin = start->getParent()->begin();
108   // If the starting point wasn't specified, but the block was, use it
109   } else if (!start && block) {
110     QI = block->end();
111     blockBegin = block->begin();
112   }
113   
114   // Walk backwards through the block, looking for dependencies
115   while (QI != blockBegin) {
116     --QI;
117     
118     // If this inst is a memory op, get the pointer it accessed
119     Value* pointer = 0;
120     uint64_t pointerSize = 0;
121     if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
122       pointer = S->getPointerOperand();
123       pointerSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
124     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
125       pointer = AI;
126       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
127         pointerSize = C->getZExtValue() *
128                       TD.getABITypeSize(AI->getAllocatedType());
129       else
130         pointerSize = ~0UL;
131     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {
132       pointer = V->getOperand(0);
133       pointerSize = TD.getTypeStoreSize(V->getType());
134     } else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
135       pointer = F->getPointerOperand();
136       
137       // FreeInsts erase the entire structure
138       pointerSize = ~0UL;
139     } else if (CallSite::get(QI).getInstruction() != 0) {
140       AliasAnalysis::ModRefBehavior result =
141                    AA.getModRefBehavior(CallSite::get(QI));
142       if (result != AliasAnalysis::DoesNotAccessMemory) {
143         if (!start && !block) {
144           cachedResult.first = QI;
145           cachedResult.second = true;
146           reverseDep[QI].insert(C.getInstruction());
147         }
148         return QI;
149       } else {
150         continue;
151       }
152     } else
153       continue;
154     
155     if (AA.getModRefInfo(C, pointer, pointerSize) != AliasAnalysis::NoModRef) {
156       if (!start && !block) {
157         cachedResult.first = QI;
158         cachedResult.second = true;
159         reverseDep[QI].insert(C.getInstruction());
160       }
161       return QI;
162     }
163   }
164   
165   // No dependence found
166   cachedResult.first = NonLocal;
167   cachedResult.second = true;
168   reverseDep[NonLocal].insert(C.getInstruction());
169   return NonLocal;
170 }
171
172 /// nonLocalHelper - Private helper used to calculate non-local dependencies
173 /// by doing DFS on the predecessors of a block to find its dependencies
174 void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
175                                               BasicBlock* block,
176                                          DenseMap<BasicBlock*, Value*>& resp) {
177   // Set of blocks that we've already visited in our DFS
178   SmallPtrSet<BasicBlock*, 4> visited;
179   // If we're updating a dirtied cache entry, we don't need to reprocess
180   // already computed entries.
181   for (DenseMap<BasicBlock*, Value*>::iterator I = resp.begin(), 
182        E = resp.end(); I != E; ++I)
183     if (I->second != Dirty)
184       visited.insert(I->first);
185   
186   // Current stack of the DFS
187   SmallVector<BasicBlock*, 4> stack;
188   for (pred_iterator PI = pred_begin(block), PE = pred_end(block);
189        PI != PE; ++PI)
190     stack.push_back(*PI);
191   
192   // Do a basic DFS
193   while (!stack.empty()) {
194     BasicBlock* BB = stack.back();
195     
196     // If we've already visited this block, no need to revist
197     if (visited.count(BB)) {
198       stack.pop_back();
199       continue;
200     }
201     
202     // If we find a new block with a local dependency for query,
203     // then we insert the new dependency and backtrack.
204     if (BB != block) {
205       visited.insert(BB);
206       
207       Instruction* localDep = getDependency(query, 0, BB);
208       if (localDep != NonLocal) {
209         resp.insert(std::make_pair(BB, localDep));
210         stack.pop_back();
211         
212         continue;
213       }
214     // If we re-encounter the starting block, we still need to search it
215     // because there might be a dependency in the starting block AFTER
216     // the position of the query.  This is necessary to get loops right.
217     } else if (BB == block) {
218       visited.insert(BB);
219       
220       Instruction* localDep = getDependency(query, 0, BB);
221       if (localDep != query)
222         resp.insert(std::make_pair(BB, localDep));
223       
224       stack.pop_back();
225       
226       continue;
227     }
228     
229     // If we didn't find anything, recurse on the precessors of this block
230     // Only do this for blocks with a small number of predecessors.
231     bool predOnStack = false;
232     bool inserted = false;
233     if (std::distance(pred_begin(BB), pred_end(BB)) <= PredLimit) { 
234       for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB);
235            PI != PE; ++PI)
236         if (!visited.count(*PI)) {
237           stack.push_back(*PI);
238           inserted = true;
239         } else
240           predOnStack = true;
241     }
242     
243     // If we inserted a new predecessor, then we'll come back to this block
244     if (inserted)
245       continue;
246     // If we didn't insert because we have no predecessors, then this
247     // query has no dependency at all.
248     else if (!inserted && !predOnStack) {
249       resp.insert(std::make_pair(BB, None));
250     // If we didn't insert because our predecessors are already on the stack,
251     // then we might still have a dependency, but it will be discovered during
252     // backtracking.
253     } else if (!inserted && predOnStack){
254       resp.insert(std::make_pair(BB, NonLocal));
255     }
256     
257     stack.pop_back();
258   }
259 }
260
261 /// getNonLocalDependency - Fills the passed-in map with the non-local 
262 /// dependencies of the queries.  The map will contain NonLocal for
263 /// blocks between the query and its dependencies.
264 void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
265                                          DenseMap<BasicBlock*, Value*>& resp) {
266   if (depGraphNonLocal.count(query)) {
267     DenseMap<BasicBlock*, Value*>& cached = depGraphNonLocal[query];
268     NumCacheNonlocal++;
269     
270     SmallVector<BasicBlock*, 4> dirtied;
271     for (DenseMap<BasicBlock*, Value*>::iterator I = cached.begin(),
272          E = cached.end(); I != E; ++I)
273       if (I->second == Dirty)
274         dirtied.push_back(I->first);
275     
276     for (SmallVector<BasicBlock*, 4>::iterator I = dirtied.begin(),
277          E = dirtied.end(); I != E; ++I) {
278       Instruction* localDep = getDependency(query, 0, *I);
279       if (localDep != NonLocal)
280         cached[*I] = localDep;
281       else {
282         cached.erase(*I);
283         nonLocalHelper(query, *I, cached);
284       }
285     }
286     
287     resp = cached;
288     
289     // Update the reverse non-local dependency cache
290     for (DenseMap<BasicBlock*, Value*>::iterator I = resp.begin(), E = resp.end();
291          I != E; ++I)
292       reverseDepNonLocal[I->second].insert(query);
293     
294     return;
295   } else
296     NumUncacheNonlocal++;
297   
298   // If not, go ahead and search for non-local deps.
299   nonLocalHelper(query, query->getParent(), resp);
300   
301   // Update the non-local dependency cache
302   for (DenseMap<BasicBlock*, Value*>::iterator I = resp.begin(), E = resp.end();
303        I != E; ++I) {
304     depGraphNonLocal[query].insert(*I);
305     reverseDepNonLocal[I->second].insert(query);
306   }
307 }
308
309 /// getDependency - Return the instruction on which a memory operation
310 /// depends.  The local parameter indicates if the query should only
311 /// evaluate dependencies within the same basic block.
312 Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
313                                                      Instruction* start,
314                                                      BasicBlock* block) {
315   // Start looking for dependencies with the queried inst
316   BasicBlock::iterator QI = query;
317   
318   // Check for a cached result
319   std::pair<Instruction*, bool>& cachedResult = depGraphLocal[query];
320   // If we have a _confirmed_ cached entry, return it
321   if (!block && !start) {
322     if (cachedResult.second)
323       return cachedResult.first;
324     else if (cachedResult.first && cachedResult.first != NonLocal)
325       // If we have an unconfirmed cached entry, we can start our search from there
326       QI = cachedResult.first;
327   }
328   
329   if (start)
330     QI = start;
331   else if (!start && block)
332     QI = block->end();
333   
334   AliasAnalysis& AA = getAnalysis<AliasAnalysis>();
335   TargetData& TD = getAnalysis<TargetData>();
336   
337   // Get the pointer value for which dependence will be determined
338   Value* dependee = 0;
339   uint64_t dependeeSize = 0;
340   bool queryIsVolatile = false;
341   if (StoreInst* S = dyn_cast<StoreInst>(query)) {
342     dependee = S->getPointerOperand();
343     dependeeSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
344     queryIsVolatile = S->isVolatile();
345   } else if (LoadInst* L = dyn_cast<LoadInst>(query)) {
346     dependee = L->getPointerOperand();
347     dependeeSize = TD.getTypeStoreSize(L->getType());
348     queryIsVolatile = L->isVolatile();
349   } else if (VAArgInst* V = dyn_cast<VAArgInst>(query)) {
350     dependee = V->getOperand(0);
351     dependeeSize = TD.getTypeStoreSize(V->getType());
352   } else if (FreeInst* F = dyn_cast<FreeInst>(query)) {
353     dependee = F->getPointerOperand();
354     
355     // FreeInsts erase the entire structure, not just a field
356     dependeeSize = ~0UL;
357   } else if (CallSite::get(query).getInstruction() != 0)
358     return getCallSiteDependency(CallSite::get(query), start, block);
359   else if (isa<AllocationInst>(query))
360     return None;
361   else
362     return None;
363   
364   BasicBlock::iterator blockBegin = block ? block->begin()
365                                           : query->getParent()->begin();
366   
367   // Walk backwards through the basic block, looking for dependencies
368   while (QI != blockBegin) {
369     --QI;
370     
371     // If this inst is a memory op, get the pointer it accessed
372     Value* pointer = 0;
373     uint64_t pointerSize = 0;
374     if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
375       // All volatile loads/stores depend on each other
376       if (queryIsVolatile && S->isVolatile()) {
377         if (!start && !block) {
378           cachedResult.first = S;
379           cachedResult.second = true;
380           reverseDep[S].insert(query);
381         }
382         
383         return S;
384       }
385       
386       pointer = S->getPointerOperand();
387       pointerSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
388     } else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
389       // All volatile loads/stores depend on each other
390       if (queryIsVolatile && L->isVolatile()) {
391         if (!start && !block) {
392           cachedResult.first = L;
393           cachedResult.second = true;
394           reverseDep[L].insert(query);
395         }
396         
397         return L;
398       }
399       
400       pointer = L->getPointerOperand();
401       pointerSize = TD.getTypeStoreSize(L->getType());
402     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
403       pointer = AI;
404       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
405         pointerSize = C->getZExtValue() * 
406                       TD.getABITypeSize(AI->getAllocatedType());
407       else
408         pointerSize = ~0UL;
409     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {
410       pointer = V->getOperand(0);
411       pointerSize = TD.getTypeStoreSize(V->getType());
412     } else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
413       pointer = F->getPointerOperand();
414       
415       // FreeInsts erase the entire structure
416       pointerSize = ~0UL;
417     } else if (CallSite::get(QI).getInstruction() != 0) {
418       // Call insts need special handling. Check if they can modify our pointer
419       AliasAnalysis::ModRefResult MR = AA.getModRefInfo(CallSite::get(QI),
420                                                       dependee, dependeeSize);
421       
422       if (MR != AliasAnalysis::NoModRef) {
423         // Loads don't depend on read-only calls
424         if (isa<LoadInst>(query) && MR == AliasAnalysis::Ref)
425           continue;
426         
427         if (!start && !block) {
428           cachedResult.first = QI;
429           cachedResult.second = true;
430           reverseDep[QI].insert(query);
431         }
432         
433         return QI;
434       } else {
435         continue;
436       }
437     }
438     
439     // If we found a pointer, check if it could be the same as our pointer
440     if (pointer) {
441       AliasAnalysis::AliasResult R = AA.alias(pointer, pointerSize,
442                                               dependee, dependeeSize);
443       
444       if (R != AliasAnalysis::NoAlias) {
445         // May-alias loads don't depend on each other
446         if (isa<LoadInst>(query) && isa<LoadInst>(QI) &&
447             R == AliasAnalysis::MayAlias)
448           continue;
449         
450         if (!start && !block) {
451           cachedResult.first = QI;
452           cachedResult.second = true;
453           reverseDep[QI].insert(query);
454         }
455         
456         return QI;
457       }
458     }
459   }
460   
461   // If we found nothing, return the non-local flag
462   if (!start && !block) {
463     cachedResult.first = NonLocal;
464     cachedResult.second = true;
465     reverseDep[NonLocal].insert(query);
466   }
467   
468   return NonLocal;
469 }
470
471 /// dropInstruction - Remove an instruction from the analysis, making 
472 /// absolutely conservative assumptions when updating the cache.  This is
473 /// useful, for example when an instruction is changed rather than removed.
474 void MemoryDependenceAnalysis::dropInstruction(Instruction* drop) {
475   depMapType::iterator depGraphEntry = depGraphLocal.find(drop);
476   if (depGraphEntry != depGraphLocal.end())
477     reverseDep[depGraphEntry->second.first].erase(drop);
478   
479   // Drop dependency information for things that depended on this instr
480   SmallPtrSet<Instruction*, 4>& set = reverseDep[drop];
481   for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
482        I != E; ++I)
483     depGraphLocal.erase(*I);
484   
485   depGraphLocal.erase(drop);
486   reverseDep.erase(drop);
487   
488   for (DenseMap<BasicBlock*, Value*>::iterator DI =
489        depGraphNonLocal[drop].begin(), DE = depGraphNonLocal[drop].end();
490        DI != DE; ++DI)
491     if (DI->second != None)
492       reverseDepNonLocal[DI->second].erase(drop);
493   
494   if (reverseDepNonLocal.count(drop)) {
495     SmallPtrSet<Instruction*, 4>& set = reverseDepNonLocal[drop];
496     for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
497          I != E; ++I)
498       for (DenseMap<BasicBlock*, Value*>::iterator DI =
499            depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end();
500            DI != DE; ++DI)
501         if (DI->second == drop)
502           DI->second = Dirty;
503   }
504   
505   reverseDepNonLocal.erase(drop);
506   nonLocalDepMapType::iterator I = depGraphNonLocal.find(drop);
507   if (I != depGraphNonLocal.end())
508     depGraphNonLocal.erase(I);
509 }
510
511 /// removeInstruction - Remove an instruction from the dependence analysis,
512 /// updating the dependence of instructions that previously depended on it.
513 /// This method attempts to keep the cache coherent using the reverse map.
514 void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
515   // Walk through the Non-local dependencies, removing this one as the value
516   // for any cached queries.
517   for (DenseMap<BasicBlock*, Value*>::iterator DI =
518        depGraphNonLocal[RemInst].begin(), DE = depGraphNonLocal[RemInst].end();
519        DI != DE; ++DI)
520     if (DI->second != None)
521       reverseDepNonLocal[DI->second].erase(RemInst);
522
523   // Shortly after this, we will look for things that depend on RemInst.  In
524   // order to update these, we'll need a new dependency to base them on.  We
525   // could completely delete any entries that depend on this, but it is better
526   // to make a more accurate approximation where possible.  Compute that better
527   // approximation if we can.
528   Instruction *NewDependency = 0;
529   bool NewDependencyConfirmed = false;
530   
531   // If we have a cached local dependence query for this instruction, remove it.
532   //
533   depMapType::iterator LocalDepEntry = depGraphLocal.find(RemInst);
534   if (LocalDepEntry != depGraphLocal.end()) {
535     Instruction *LocalDepInst = LocalDepEntry->second.first;
536     bool IsConfirmed = LocalDepEntry->second.second;
537     
538     // Remove this local dependency info.
539     depGraphLocal.erase(LocalDepEntry);
540     
541     // Remove us from DepInst's reverse set now that the local dep info is gone.
542     reverseDep[LocalDepInst].erase(RemInst);
543
544     // If we have unconfirmed info, don't trust it.
545     if (IsConfirmed) {
546       // If we have a confirmed non-local flag, use it.
547       if (LocalDepInst == NonLocal || LocalDepInst == None) {
548         // The only time this dependency is confirmed is if it is non-local.
549         NewDependency = LocalDepInst;
550         NewDependencyConfirmed = true;
551       } else {
552         // If we have dep info for RemInst, set them to it.
553         NewDependency = next(BasicBlock::iterator(LocalDepInst));
554         
555         // Don't use RI for the new dependency!
556         if (NewDependency == RemInst)
557           NewDependency = 0;
558       }
559     }
560   }
561   
562   // If we don't already have a local dependency answer for this instruction,
563   // use the immediate successor of RemInst.  We use the successor because
564   // getDependence starts by checking the immediate predecessor of what is in
565   // the cache.
566   if (NewDependency == 0)
567     NewDependency = next(BasicBlock::iterator(RemInst));
568   
569   // Loop over all of the things that depend on the instruction we're removing.
570   // 
571   reverseDepMapType::iterator ReverseDepIt = reverseDep.find(RemInst);
572   if (ReverseDepIt != reverseDep.end()) {
573     SmallPtrSet<Instruction*, 4> &ReverseDeps = ReverseDepIt->second;
574     for (SmallPtrSet<Instruction*, 4>::iterator I = ReverseDeps.begin(),
575          E = ReverseDeps.end(); I != E; ++I) {
576       Instruction *InstDependingOnRemInst = *I;
577       
578       // If we thought the instruction depended on itself (possible for
579       // unconfirmed dependencies) ignore the update.
580       if (InstDependingOnRemInst == RemInst) continue;
581       
582       // Insert the new dependencies.
583       depGraphLocal[InstDependingOnRemInst] =
584         std::make_pair(NewDependency, NewDependencyConfirmed);
585       
586       // If our NewDependency is an instruction, make sure to remember that new
587       // things depend on it.
588       if (NewDependency != NonLocal && NewDependency != None)
589         reverseDep[NewDependency].insert(InstDependingOnRemInst);
590     }
591     reverseDep.erase(RemInst);
592   }
593   
594   ReverseDepIt = reverseDepNonLocal.find(RemInst);
595   if (ReverseDepIt != reverseDepNonLocal.end()) {
596     SmallPtrSet<Instruction*, 4>& set = ReverseDepIt->second;
597     for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
598          I != E; ++I)
599       for (DenseMap<BasicBlock*, Value*>::iterator DI =
600            depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end();
601            DI != DE; ++DI)
602         if (DI->second == RemInst)
603           DI->second = Dirty;
604     reverseDepNonLocal.erase(RemInst);
605   }
606   
607   depGraphNonLocal.erase(RemInst);
608
609   getAnalysis<AliasAnalysis>().deleteValue(RemInst);
610   
611   DEBUG(verifyRemoved(RemInst));
612 }