implement a fixme by introducing a new getDependencyFromInternal
method that returns its result as a DepResultTy instead of as a
MemDepResult.  This reduces conversion back and forth.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60266 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index b034f7d..94a3d1b 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -47,7 +47,7 @@
 
 /// getCallSiteDependency - Private helper for finding the local dependencies
 /// of a call site.
-MemDepResult MemoryDependenceAnalysis::
+MemoryDependenceAnalysis::DepResultTy MemoryDependenceAnalysis::
 getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
                       BasicBlock *BB) {
   AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
@@ -84,24 +84,24 @@
       if (AA.getModRefBehavior(CallSite::get(Inst)) ==
             AliasAnalysis::DoesNotAccessMemory)
         continue;
-      return MemDepResult::get(Inst);
+      return DepResultTy(Inst, Normal);
     } else
       continue;
     
     if (AA.getModRefInfo(C, Pointer, PointerSize) != AliasAnalysis::NoModRef)
-      return MemDepResult::get(Inst);
+      return DepResultTy(Inst, Normal);
   }
   
   // No dependence found.
-  return MemDepResult::getNonLocal();
+  return DepResultTy(0, NonLocal);
 }
 
 /// getDependency - Return the instruction on which a memory operation
 /// depends.  The local parameter indicates if the query should only
 /// evaluate dependencies within the same basic block.
-MemDepResult MemoryDependenceAnalysis::
-getDependencyFrom(Instruction *QueryInst, BasicBlock::iterator ScanIt, 
-                  BasicBlock *BB) {
+MemoryDependenceAnalysis::DepResultTy MemoryDependenceAnalysis::
+getDependencyFromInternal(Instruction *QueryInst, BasicBlock::iterator ScanIt, 
+                          BasicBlock *BB) {
   AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
   TargetData &TD = getAnalysis<TargetData>();
   
@@ -128,7 +128,7 @@
   } else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst))
     return getCallSiteDependency(CallSite::get(QueryInst), ScanIt, BB);
   else  // Non-memory instructions depend on nothing.
-    return MemDepResult::getNone();
+    return DepResultTy(0, None);
   
   // Walk backwards through the basic block, looking for dependencies
   while (ScanIt != BB->begin()) {
@@ -139,7 +139,7 @@
     if (MemVolatile &&
         ((isa<LoadInst>(Inst) && cast<LoadInst>(Inst)->isVolatile()) ||
          (isa<StoreInst>(Inst) && cast<StoreInst>(Inst)->isVolatile())))
-      return MemDepResult::get(Inst);
+      return DepResultTy(Inst, Normal);
 
     // MemDep is broken w.r.t. loads: it says that two loads of the same pointer
     // depend on each other.  :(
@@ -157,7 +157,7 @@
       // May-alias loads don't depend on each other without a dependence.
       if (isa<LoadInst>(QueryInst) && R == AliasAnalysis::MayAlias)
         continue;
-      return MemDepResult::get(Inst);
+      return DepResultTy(Inst, Normal);
     }
     
     // FIXME: This claims that an access depends on the allocation.  This may
@@ -179,7 +179,7 @@
       
       if (R == AliasAnalysis::NoAlias)
         continue;
-      return MemDepResult::get(Inst);
+      return DepResultTy(Inst, Normal);
     }
       
     
@@ -194,11 +194,11 @@
       continue;
     
     // Otherwise, there is a dependence.
-    return MemDepResult::get(Inst);
+    return DepResultTy(Inst, Normal);
   }
   
   // If we found nothing, return the non-local flag.
-  return MemDepResult::getNonLocal();
+  return DepResultTy(0, NonLocal);
 }
 
 /// getDependency - Return the instruction on which a memory operation
@@ -220,16 +220,14 @@
     ScanPos = Inst;
   
   // Do the scan.
-  MemDepResult Res = 
-    getDependencyFrom(QueryInst, ScanPos, QueryInst->getParent());  
+  LocalCache = getDependencyFromInternal(QueryInst, ScanPos,
+                                         QueryInst->getParent());
   
   // Remember the result!
-  // FIXME: Don't convert back and forth!  Make a shared helper function.
-  LocalCache = ConvFromResult(Res);
-  if (Instruction *I = Res.getInst())
+  if (Instruction *I = LocalCache.getPointer())
     ReverseLocalDeps[I].insert(QueryInst);
   
-  return Res;
+  return ConvToResult(LocalCache);
 }
 
 /// getNonLocalDependency - Perform a full dependency query for the
@@ -287,17 +285,14 @@
     // If DirtyBBEntry isn't dirty, it ended up on the worklist multiple times.
     if (DirtyBBEntry.getInt() != Dirty) continue;
 
-    // Find out if this block has a local dependency for QueryInst.
-    // FIXME: Don't convert back and forth for MemDepResult <-> DepResultTy.
-    
     // If the dirty entry has a pointer, start scanning from it so we don't have
     // to rescan the entire block.
     BasicBlock::iterator ScanPos = DirtyBB->end();
     if (Instruction *Inst = DirtyBBEntry.getPointer())
       ScanPos = Inst;
     
-    DirtyBBEntry = ConvFromResult(getDependencyFrom(QueryInst, ScanPos,
-                                                    DirtyBB));
+    // Find out if this block has a local dependency for QueryInst.
+    DirtyBBEntry = getDependencyFromInternal(QueryInst, ScanPos, DirtyBB);
            
     // If the block has a dependency (i.e. it isn't completely transparent to
     // the value), remember it!