From f29807169adff54d46762928a7f2d6b697886df1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 26 Jul 2004 06:14:11 +0000 Subject: [PATCH] Implement DeadStoreElim/alloca.llx by observing that allocas are dead at the end of the function (either return or unwind) llvm-svn: 15232 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 36aaa63449b1..40b5671e4c68 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -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(I)) + KillLocs.add(AI, ~0); } // PotentiallyDeadInsts - Deleting dead stores from the program can make other