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
This commit is contained in:
Owen Anderson
2008-07-02 17:20:16 +00:00
parent bee98c66c0
commit f2aa160b35
3 changed files with 41 additions and 13 deletions

View File

@@ -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);