mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
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
This commit is contained in:
@@ -74,14 +74,22 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
// Do a top-down walk on the BB
|
// Do a top-down walk on the BB
|
||||||
for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ++BBI) {
|
for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ++BBI) {
|
||||||
// If we find a store...
|
// If we find a store...
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
|
if (isa<StoreInst>(BBI) || isa<FreeInst>(BBI)) {
|
||||||
StoreInst*& last = lastStore[S->getPointerOperand()];
|
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...
|
// ... to a pointer that has been stored to before...
|
||||||
if (last) {
|
if (last) {
|
||||||
|
|
||||||
// ... and no other memory dependencies are between them....
|
// ... and no other memory dependencies are between them....
|
||||||
if (MD.getDependency(S) == last) {
|
if (MD.getDependency(BBI) == last) {
|
||||||
|
|
||||||
// Remove it!
|
// Remove it!
|
||||||
MD.removeInstruction(last);
|
MD.removeInstruction(last);
|
||||||
|
|
||||||
@@ -96,7 +104,10 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update our most-recent-store map
|
// Update our most-recent-store map
|
||||||
|
if (StoreInst* S = dyn_cast<StoreInst>(BBI))
|
||||||
last = S;
|
last = S;
|
||||||
|
else
|
||||||
|
last = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user