summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-28 20:44:37 +0000
committerChris Lattner <sabre@nondot.org>2004-11-28 20:44:37 +0000
commit6ea28888325bb0ec48d8827caf44f2489f643fab (patch)
tree18173d73f2dc2380c10f18a028b9d0e4b0d80b40 /llvm/lib
parent1b784b117d32278888945b60290441fcbf19e82a (diff)
downloadbcm5719-llvm-6ea28888325bb0ec48d8827caf44f2489f643fab.tar.gz
bcm5719-llvm-6ea28888325bb0ec48d8827caf44f2489f643fab.zip
Make DSE potentially more aggressive by being more specific about alloca sizes.
llvm-svn: 18309
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index c7f3254d4c7..27a0b0a881f 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -16,6 +16,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Analysis/AliasAnalysis.h"
@@ -63,13 +64,18 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
AliasSetTracker KillLocs(AA);
- // If this block ends in a return, unwind, and eventually tailcall/barrier,
- // then all allocas are dead at its end.
+ // If this block ends in a return, unwind, unreachable, and eventually
+ // tailcall, 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);
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
+ unsigned Size = ~0U;
+ if (!AI->isArrayAllocation() &&
+ AI->getType()->getElementType()->isSized())
+ Size = TD.getTypeSize(AI->getType()->getElementType());
+ KillLocs.add(AI, Size);
+ }
}
// PotentiallyDeadInsts - Deleting dead stores from the program can make other
OpenPOWER on IntegriCloud