diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-25 07:58:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-25 07:58:38 +0000 |
commit | 4c1c1ac7e4b581ed5038d4da1738248306e4d392 (patch) | |
tree | 7caaa3f5531b05939efd4c8f8a34130cc67f892e /llvm | |
parent | fb7dd4c1a3e04ab766c95ffd167c8b74aba8fa84 (diff) | |
download | bcm5719-llvm-4c1c1ac7e4b581ed5038d4da1738248306e4d392.tar.gz bcm5719-llvm-4c1c1ac7e4b581ed5038d4da1738248306e4d392.zip |
Free instructions kill values too. This implements DeadStoreElim/free.llx
llvm-svn: 15199
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 9498f1273c0..c38ef38e64d 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/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; |