Implement DeadStoreElim/alloca.llx by observing that allocas are dead at the

end of the function (either return or unwind)

llvm-svn: 15232
This commit is contained in:
Chris Lattner 2004-07-26 06:14:11 +00:00
parent 988d70c732
commit f29807169a
1 changed files with 4 additions and 1 deletions

View File

@ -66,7 +66,10 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// If this block ends in a return, unwind, and eventually tailcall/barrier,
// then all allocas are dead at its end.
if (BB.getTerminator()->getNumSuccessors() == 0) {
BasicBlock *Entry = BB.getParent()->begin();
for (BasicBlock::iterator I = Entry->begin(), E = Entry->end(); I != E; ++I)
if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
KillLocs.add(AI, ~0);
}
// PotentiallyDeadInsts - Deleting dead stores from the program can make other