[llvm-commits] [llvm] r39753 - /llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
Owen Anderson
resistor at mac.com
Wed Jul 11 13:38:34 PDT 2007
Author: resistor
Date: Wed Jul 11 15:38:34 2007
New Revision: 39753
URL: http://llvm.org/viewvc/llvm-project?rev=39753&view=rev
Log:
Handle eliminating stores that occur right before a free.
Modified:
llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp?rev=39753&r1=39752&r2=39753&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/FastDSE.cpp Wed Jul 11 15:38:34 2007
@@ -74,14 +74,22 @@
// 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 @@
}
// Update our most-recent-store map
- last = S;
+ if (StoreInst* S = dyn_cast<StoreInst>(BBI))
+ last = S;
+ else
+ last = 0;
}
}
More information about the llvm-commits
mailing list