mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-05 09:24:28 +00:00
Remove the end-block handling code. It was unsafe, and making it safe would have resulted in falling back to the slow DSE case. I need to think some more about the right way to handle this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39788 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -122,11 +122,6 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this block ends in a return, unwind, unreachable, and eventually
|
|
||||||
// tailcall, then all allocas are dead at its end.
|
|
||||||
if (BB.getTerminator()->getNumSuccessors() == 0)
|
|
||||||
MadeChange |= handleEndBlock(BB, possiblyDead);
|
|
||||||
|
|
||||||
// Do a trivial DCE
|
// Do a trivial DCE
|
||||||
while (!possiblyDead.empty()) {
|
while (!possiblyDead.empty()) {
|
||||||
Instruction *I = possiblyDead.back();
|
Instruction *I = possiblyDead.back();
|
||||||
@ -168,56 +163,6 @@ bool FDSE::handleFreeWithNonTrivialDependency(FreeInst* F, StoreInst* dependency
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// handleEndBlock - Remove dead stores to stack-allocated locations in the function
|
|
||||||
/// end block
|
|
||||||
bool FDSE::handleEndBlock(BasicBlock& BB, SetVector<Instruction*>& possiblyDead) {
|
|
||||||
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
|
||||||
|
|
||||||
bool MadeChange = false;
|
|
||||||
|
|
||||||
// Pointers alloca'd in this function are dead in the end block
|
|
||||||
SmallPtrSet<AllocaInst*, 4> deadPointers;
|
|
||||||
|
|
||||||
// Find all of the alloca'd pointers in the entry block
|
|
||||||
BasicBlock *Entry = BB.getParent()->begin();
|
|
||||||
for (BasicBlock::iterator I = Entry->begin(), E = Entry->end(); I != E; ++I)
|
|
||||||
if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
|
|
||||||
deadPointers.insert(AI);
|
|
||||||
|
|
||||||
// Scan the basic block backwards
|
|
||||||
for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){
|
|
||||||
--BBI;
|
|
||||||
|
|
||||||
if (deadPointers.empty())
|
|
||||||
break;
|
|
||||||
|
|
||||||
// If we find a store whose pointer is dead...
|
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
|
|
||||||
if (deadPointers.count(S->getPointerOperand())){
|
|
||||||
// Remove it!
|
|
||||||
MD.removeInstruction(S);
|
|
||||||
|
|
||||||
// DCE instructions only used to calculate that store
|
|
||||||
if (Instruction* D = dyn_cast<Instruction>(S->getOperand(0)))
|
|
||||||
possiblyDead.insert(D);
|
|
||||||
|
|
||||||
BBI++;
|
|
||||||
S->eraseFromParent();
|
|
||||||
NumFastStores++;
|
|
||||||
MadeChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we encounter a use of the pointer, it is no longer considered dead
|
|
||||||
} else if (LoadInst* L = dyn_cast<LoadInst>(BBI)) {
|
|
||||||
deadPointers.erase(L->getPointerOperand());
|
|
||||||
} else if (VAArgInst* V = dyn_cast<VAArgInst>(BBI)) {
|
|
||||||
deadPointers.erase(V->getOperand(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MadeChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FDSE::DeleteDeadInstructionChains(Instruction *I,
|
void FDSE::DeleteDeadInstructionChains(Instruction *I,
|
||||||
SetVector<Instruction*> &DeadInsts) {
|
SetVector<Instruction*> &DeadInsts) {
|
||||||
// Instruction must be dead.
|
// Instruction must be dead.
|
||||||
|
Reference in New Issue
Block a user