Cleanup of the [SU]ADDO type legalization code. Patch by Duncan!
[oota-llvm.git] / lib / Analysis / MemoryDependenceAnalysis.cpp
index 1cd16bb06de03c669d7c28dcad5f6c2352415ee1..d5b0afccb9b01c23aae116334727fa5c9cfabe11 100644 (file)
@@ -19,7 +19,6 @@
 #include "llvm/Instructions.h"
 #include "llvm/Function.h"
 #include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/Dominators.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Target/TargetData.h"
@@ -83,7 +82,6 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
   AU.addRequiredTransitive<AliasAnalysis>();
   AU.addRequiredTransitive<TargetData>();
-  AU.addRequiredTransitive<DominatorTree>();
 }
 
 /// getCallSiteDependency - Private helper for finding the local dependencies
@@ -99,7 +97,7 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
   BasicBlock::iterator blockBegin = C.getInstruction()->getParent()->begin();
   BasicBlock::iterator QI = C.getInstruction();
   
-  // If the starting point was specifiy, use it
+  // If the starting point was specified, use it
   if (start) {
     QI = start;
     blockBegin = start->getParent()->begin();
@@ -224,17 +222,6 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
       continue;
     }
     
-    // Don't recur upwards if the current block is unreachable.
-    // Instead, mark it as having no dependency on this path,
-    // which will block optzns from occuring.  For this reason,
-    // eliminating unreachable blocks before running a memdep
-    // based optimization is recommended.
-    DominatorTree& DT = getAnalysis<DominatorTree>();
-    if (!DT.isReachableFromEntry(BB)) {
-      resp.insert(std::make_pair(BB, None));
-      continue;
-    }
-    
     // If we didn't find anything, recurse on the precessors of this block
     // Only do this for blocks with a small number of predecessors.
     bool predOnStack = false;
@@ -541,6 +528,10 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
       // If we have dep info for rem, set them to it
       BasicBlock::iterator RI = depGraphEntry->second.first;
       RI++;
+      
+      // If RI is rem, then we use rem's immediate successor.
+      if (RI == (BasicBlock::iterator)rem) RI++;
+      
       newDep = RI;
     } else if ( (depGraphEntry->second.first == NonLocal ||
                  depGraphEntry->second.first == None ) &&