aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-07-02 17:20:16 +0000
committerOwen Anderson <resistor@mac.com>2008-07-02 17:20:16 +0000
commitf2aa160b357c98d8c37b69ea9775aa3e097d1319 (patch)
treebad306be76337b3a4dac25790e1644b4682642cb /lib
parentbee98c66c0c3d1f43244cdf237e572a9df031e40 (diff)
A better fix for PR2503 that doesn't pessimize GVN in the presence of unreachable blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp13
-rw-r--r--lib/Transforms/Scalar/GVN.cpp5
2 files changed, 5 insertions, 13 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index 1cd16bb06d..2012ab473c 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -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
@@ -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;
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 5564dbde1b..590227c27f 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -808,6 +808,11 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig,
DenseMap<BasicBlock*, Value*>::iterator V = Phis.find(BB);
if (V != Phis.end() && !top_level) return V->second;
+ if (!getAnalysis<DominatorTree>().isReachableFromEntry(BB)) {
+ Phis[BB] = UndefValue::get(orig->getType());
+ return UndefValue::get(orig->getType());
+ }
+
BasicBlock* singlePred = BB->getSinglePredecessor();
if (singlePred) {
Value *ret = GetValueForBlock(singlePred, orig, Phis);