Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | for (Function::iterator I = F.begin(), E = F.end(); I != E;) { | ||||
continue; | continue; | ||||
} | } | ||||
BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator()); | BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator()); | ||||
// Can't thread an unconditional jump, but if the block is "almost | // Can't thread an unconditional jump, but if the block is "almost | ||||
// empty", we can replace uses of it with uses of the successor and make | // empty", we can replace uses of it with uses of the successor and make | ||||
// this dead. | // this dead. | ||||
// We should not eliminate the loop header either, because eliminating | // We should not eliminate the loop header or latch either, because | ||||
// a loop header might later prevent LoopSimplify from transforming nested | // eliminating a loop header or latch might later prevent LoopSimplify | ||||
// loops into simplified form. | // from transforming nested loops into simplified form. We will rely on | ||||
// later passes in backend to clean up empty blocks. | |||||
if (BI && BI->isUnconditional() && | if (BI && BI->isUnconditional() && | ||||
BB != &BB->getParent()->getEntryBlock() && | BB != &BB->getParent()->getEntryBlock() && | ||||
// If the terminator is the only non-phi instruction, try to nuke it. | // If the terminator is the only non-phi instruction, try to nuke it. | ||||
BB->getFirstNonPHIOrDbg()->isTerminator() && !LoopHeaders.count(BB)) { | BB->getFirstNonPHIOrDbg()->isTerminator() && !LoopHeaders.count(BB) && | ||||
!LoopHeaders.count(BI->getSuccessor(0))) { | |||||
// FIXME: It is always conservatively correct to drop the info | // FIXME: It is always conservatively correct to drop the info | ||||
// for a block even if it doesn't get erased. This isn't totally | // for a block even if it doesn't get erased. This isn't totally | ||||
// awesome, but it allows us to use AssertingVH to prevent nasty | // awesome, but it allows us to use AssertingVH to prevent nasty | ||||
// dangling pointer issues within LazyValueInfo. | // dangling pointer issues within LazyValueInfo. | ||||
LVI->eraseBlock(BB); | LVI->eraseBlock(BB); | ||||
if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) | if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) | ||||
Changed = true; | Changed = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,125 Lines • Show Last 20 Lines |