make clients have to know how to call getCallSiteDependencyFrom
[oota-llvm.git] / lib / Analysis / MemoryDependenceAnalysis.cpp
index 9dad8bcf45c56e1f69aa97ef5b9d122d371171ea..415766a5a15c4f31a6c862f4f2d2f6c5bce64bbd 100644 (file)
@@ -118,14 +118,14 @@ getDependencyFrom(Instruction *QueryInst, BasicBlock::iterator ScanIt,
   Value *MemPtr = 0;
   uint64_t MemSize = 0;
   
-  if (StoreInst *S = dyn_cast<StoreInst>(QueryInst)) {
+  if (StoreInst *SI = dyn_cast<StoreInst>(QueryInst)) {
     // If this is a volatile store, don't mess around with it.  Just return the
     // previous instruction as a clobber.
-    if (S->isVolatile())
+    if (SI->isVolatile())
       return MemDepResult::getClobber(--ScanIt);
 
-    MemPtr = S->getPointerOperand();
-    MemSize = TD->getTypeStoreSize(S->getOperand(0)->getType());
+    MemPtr = SI->getPointerOperand();
+    MemSize = TD->getTypeStoreSize(SI->getOperand(0)->getType());
   } else if (LoadInst *LI = dyn_cast<LoadInst>(QueryInst)) {
     // If this is a volatile load, don't mess around with it.  Just return the
     // previous instruction as a clobber.
@@ -134,11 +134,12 @@ getDependencyFrom(Instruction *QueryInst, BasicBlock::iterator ScanIt,
     
     MemPtr = LI->getPointerOperand();
     MemSize = TD->getTypeStoreSize(LI->getType());
-  } else if (FreeInst* F = dyn_cast<FreeInst>(QueryInst)) {
-    MemPtr = F->getPointerOperand();
+  } else if (FreeInst *FI = dyn_cast<FreeInst>(QueryInst)) {
+    MemPtr = FI->getPointerOperand();
     // FreeInsts erase the entire structure, not just a field.
     MemSize = ~0UL;
   } else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)) {
+    assert(0 && "Should use getCallSiteDependencyFrom!");
     return getCallSiteDependencyFrom(CallSite::get(QueryInst), ScanIt, BB);
   } else {
     // Otherwise, this is a vaarg or non-memory instruction, just return a
@@ -233,7 +234,11 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) {
   }
   
   // Do the scan.
-  LocalCache = getDependencyFrom(QueryInst, ScanPos, QueryInst->getParent());
+  if (!isa<CallInst>(QueryInst) && !isa<InvokeInst>(QueryInst))
+    LocalCache = getDependencyFrom(QueryInst, ScanPos, QueryInst->getParent());
+  else 
+    LocalCache = getCallSiteDependencyFrom(CallSite::get(QueryInst), ScanPos,
+                                           QueryInst->getParent());
   
   // Remember the result!
   if (Instruction *I = LocalCache.getInst())
@@ -341,7 +346,12 @@ MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) {
     }
     
     // Find out if this block has a local dependency for QueryInst.
-    MemDepResult Dep = getDependencyFrom(QueryInst, ScanPos, DirtyBB);
+    MemDepResult Dep;
+    if (!isa<CallInst>(QueryInst) && !isa<InvokeInst>(QueryInst))
+      Dep = getDependencyFrom(QueryInst, ScanPos, DirtyBB);
+    else 
+      Dep = getCallSiteDependencyFrom(CallSite::get(QueryInst), ScanPos,
+                                      DirtyBB);
     
     // If we had a dirty entry for the block, update it.  Otherwise, just add
     // a new entry.
@@ -368,6 +378,7 @@ MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) {
   return Cache;
 }
 
+
 /// 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.