[llvm-commits] [llvm] r52946 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Owen Anderson resistor at mac.com
Mon Jun 30 17:41:04 PDT 2008


Author: resistor
Date: Mon Jun 30 19:40:58 2008
New Revision: 52946

URL: http://llvm.org/viewvc/llvm-project?rev=52946&view=rev
Log:
Properly handle cases where a predecessor of the block being queried on is unreachable.
This fixes PR2503, though we should also fix other passes not to emit this kind of code.

Modified:
    llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=52946&r1=52945&r2=52946&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Jun 30 19:40:58 2008
@@ -19,6 +19,7 @@
 #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"
@@ -82,6 +83,7 @@
   AU.setPreservesAll();
   AU.addRequiredTransitive<AliasAnalysis>();
   AU.addRequiredTransitive<TargetData>();
+  AU.addRequiredTransitive<DominatorTree>();
 }
 
 /// getCallSiteDependency - Private helper for finding the local dependencies
@@ -222,6 +224,17 @@
       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;





More information about the llvm-commits mailing list