diff options
author | Owen Anderson <resistor@mac.com> | 2008-07-01 00:40:58 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-07-01 00:40:58 +0000 |
commit | c4b871c650d4030031545a5a2d07ecaa48c80a9c (patch) | |
tree | d78cc2a3442ca01edffe87eab1f3f649ec33fb8b /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | f4f9c4f1cf4d497c63e40e6c7ef545c8c716a5ce (diff) | |
download | external_llvm-c4b871c650d4030031545a5a2d07ecaa48c80a9c.zip external_llvm-c4b871c650d4030031545a5a2d07ecaa48c80a9c.tar.gz external_llvm-c4b871c650d4030031545a5a2d07ecaa48c80a9c.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 2012ab4..1cd16bb 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -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 @@ 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 @@ -222,6 +224,17 @@ 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; |