Fix the types for NumElements variables, and add a comment
[oota-llvm.git] / lib / Analysis / MemoryDependenceAnalysis.cpp
index 161c2fed1c7112658c13715a9355be3746fea86d..2012ab473c98a697650a37a94129bc67a0c1f347 100644 (file)
 
 using namespace llvm;
 
-namespace {
-  // Control the calculation of non-local dependencies by only examining the
-  // predecessors if the basic block has less than X amount (50 by default).
-  cl::opt<int> 
-  PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
-            cl::desc("Control the calculation of non-local"
-                     "dependencies (default = 50)"));           
-}
+// Control the calculation of non-local dependencies by only examining the
+// predecessors if the basic block has less than X amount (50 by default).
+static cl::opt<int> 
+PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
+          cl::desc("Control the calculation of non-local"
+                   "dependencies (default = 50)"));           
 
 STATISTIC(NumCacheNonlocal, "Number of cached non-local responses");
 STATISTIC(NumUncacheNonlocal, "Number of uncached non-local responses");
@@ -60,6 +58,9 @@ void MemoryDependenceAnalysis::ping(Instruction *D) {
   for (nonLocalDepMapType::iterator I = depGraphNonLocal.begin(), E = depGraphNonLocal.end();
        I != E; ++I) {
     assert(I->first != D);
+    for (DenseMap<BasicBlock*, Value*>::iterator II = I->second.begin(),
+         EE = I->second.end(); II  != EE; ++II)
+      assert(II->second != D);
   }
 
   for (reverseDepMapType::iterator I = reverseDep.begin(), E = reverseDep.end();
@@ -131,7 +132,7 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
       
       // FreeInsts erase the entire structure
       pointerSize = ~0UL;
-    } else if (isa<CallInst>(QI)) {
+    } else if (CallSite::get(QI).getInstruction() != 0) {
       AliasAnalysis::ModRefBehavior result =
                    AA.getModRefBehavior(CallSite::get(QI));
       if (result != AliasAnalysis::DoesNotAccessMemory) {
@@ -281,6 +282,11 @@ void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
     
     resp = cached;
     
+    // Update the reverse non-local dependency cache
+    for (DenseMap<BasicBlock*, Value*>::iterator I = resp.begin(), E = resp.end();
+         I != E; ++I)
+      reverseDepNonLocal[I->second].insert(query);
+    
     return;
   } else
     NumUncacheNonlocal++;