aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-07-11 20:38:34 +0000
committerOwen Anderson <resistor@mac.com>2007-07-11 20:38:34 +0000
commit2655adb3b26b845193be9802f6f938d836c4a939 (patch)
tree25e69f847989764ea575afddd269337235849eba
parenta126bb71d5ba119fcddabfe022fad9647b9f1bf0 (diff)
Handle eliminating stores that occur right before a free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39753 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/FastDSE.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/FastDSE.cpp b/lib/Transforms/Scalar/FastDSE.cpp
index e344f55e82..82862f7b48 100644
--- a/lib/Transforms/Scalar/FastDSE.cpp
+++ b/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;
}
}