diff options
| author | Owen Anderson <resistor@mac.com> | 2007-07-11 20:38:34 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2007-07-11 20:38:34 +0000 |
| commit | e72014483730f4940ef1710090d15085276738fc (patch) | |
| tree | 155f8b80964b81df7e2ddac359cca3c5775f6b3e /llvm | |
| parent | 3d70855dd2d6f6f7d78c336fa27cf298db65bb82 (diff) | |
| download | bcm5719-llvm-e72014483730f4940ef1710090d15085276738fc.tar.gz bcm5719-llvm-e72014483730f4940ef1710090d15085276738fc.zip | |
Handle eliminating stores that occur right before a free.
llvm-svn: 39753
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/FastDSE.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/FastDSE.cpp b/llvm/lib/Transforms/Scalar/FastDSE.cpp index e344f55e823..82862f7b489 100644 --- a/llvm/lib/Transforms/Scalar/FastDSE.cpp +++ b/llvm/lib/Transforms/Scalar/FastDSE.cpp @@ -74,14 +74,22 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) { // Do a top-down walk on the BB for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ++BBI) { // If we find a store... - if (StoreInst* S = dyn_cast<StoreInst>(BBI)) { - StoreInst*& last = lastStore[S->getPointerOperand()]; + if (isa<StoreInst>(BBI) || isa<FreeInst>(BBI)) { + Value* pointer = 0; + if (StoreInst* S = dyn_cast<StoreInst>(BBI)) + pointer = S->getPointerOperand(); + else if (FreeInst* F = dyn_cast<FreeInst>(BBI)) + pointer = F->getPointerOperand(); + assert(pointer && "Not a free or a store?"); + + StoreInst*& last = lastStore[pointer]; // ... to a pointer that has been stored to before... if (last) { // ... and no other memory dependencies are between them.... - if (MD.getDependency(S) == last) { + if (MD.getDependency(BBI) == last) { + // Remove it! MD.removeInstruction(last); @@ -96,7 +104,10 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) { } // Update our most-recent-store map - last = S; + if (StoreInst* S = dyn_cast<StoreInst>(BBI)) + last = S; + else + last = 0; } } |

