aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-25 07:58:38 +0000
committerChris Lattner <sabre@nondot.org>2004-07-25 07:58:38 +0000
commita9e2f3d0ab721d6a46dc3a6962d834b3e1c51494 (patch)
tree94233f4bca1fe5718fb0a63ec6c51f4f63216053 /lib
parent9ec6e46ad8a299a26e7838c103c8c6d5acfaf206 (diff)
Free instructions kill values too. This implements DeadStoreElim/free.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 9498f1273c..c38ef38e64 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -79,7 +79,8 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
}
#endif
- if (!isa<StoreInst>(I) || cast<StoreInst>(I)->isVolatile()) {
+ if (!isa<FreeInst>(I) &&
+ (!isa<StoreInst>(I) || cast<StoreInst>(I)->isVolatile())) {
// If this is a non-store instruction, it makes everything referenced no
// longer killed. Remove anything aliased from the alias set tracker.
KillLocs.remove(I);
@@ -90,8 +91,16 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// the stored location is already in the tracker, then this is a dead
// store. We can just delete it here, but while we're at it, we also
// delete any trivially dead expression chains.
- unsigned ValSize = TD.getTypeSize(I->getOperand(0)->getType());
- Value *Ptr = I->getOperand(1);
+ unsigned ValSize;
+ Value *Ptr;
+ if (isa<StoreInst>(I)) {
+ Ptr = I->getOperand(1);
+ ValSize = TD.getTypeSize(I->getOperand(0)->getType());
+ } else {
+ Ptr = I->getOperand(0);
+ ValSize = ~0;
+ }
+
if (AliasSet *AS = KillLocs.getAliasSetForPointerIfExists(Ptr, ValSize))
for (AliasSet::iterator ASI = AS->begin(), E = AS->end(); ASI != E; ++ASI)
if (AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize)
@@ -110,7 +119,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// Otherwise, this is a non-dead store just add it to the set of dead
// locations.
- KillLocs.add(cast<StoreInst>(I));
+ KillLocs.add(I);
BigContinue:;
}
return MadeChange;