mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-06 17:24:34 +00:00
Make the condition-checking for free with non-trivial dependencies more correct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39789 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -46,9 +46,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool runOnBasicBlock(BasicBlock &BB);
|
bool runOnBasicBlock(BasicBlock &BB);
|
||||||
bool handleFreeWithNonTrivialDependency(FreeInst* F, StoreInst* dependency,
|
bool handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dependency,
|
||||||
SetVector<Instruction*>& possiblyDead);
|
SetVector<Instruction*>& possiblyDead);
|
||||||
bool handleEndBlock(BasicBlock& BB, SetVector<Instruction*>& possiblyDead);
|
|
||||||
void DeleteDeadInstructionChains(Instruction *I,
|
void DeleteDeadInstructionChains(Instruction *I,
|
||||||
SetVector<Instruction*> &DeadInsts);
|
SetVector<Instruction*> &DeadInsts);
|
||||||
|
|
||||||
@ -91,6 +90,7 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
assert(pointer && "Not a free or a store?");
|
assert(pointer && "Not a free or a store?");
|
||||||
|
|
||||||
StoreInst*& last = lastStore[pointer];
|
StoreInst*& last = lastStore[pointer];
|
||||||
|
bool deletedStore = false;
|
||||||
|
|
||||||
// ... to a pointer that has been stored to before...
|
// ... to a pointer that has been stored to before...
|
||||||
if (last) {
|
if (last) {
|
||||||
@ -107,13 +107,17 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
|
|
||||||
last->eraseFromParent();
|
last->eraseFromParent();
|
||||||
NumFastStores++;
|
NumFastStores++;
|
||||||
|
deletedStore = true;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
|
}
|
||||||
// If this is a free, check for a non-trivial dependency
|
|
||||||
} else if (FreeInst* F = dyn_cast<FreeInst>(BBI))
|
|
||||||
MadeChange |= handleFreeWithNonTrivialDependency(F, last, possiblyDead);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle frees whose dependencies are non-trivial
|
||||||
|
if (FreeInst* F = dyn_cast<FreeInst>(BBI))
|
||||||
|
if (!deletedStore)
|
||||||
|
MadeChange |= handleFreeWithNonTrivialDependency(F, MD.getDependency(F),
|
||||||
|
possiblyDead);
|
||||||
|
|
||||||
// Update our most-recent-store map
|
// Update our most-recent-store map
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(BBI))
|
if (StoreInst* S = dyn_cast<StoreInst>(BBI))
|
||||||
last = S;
|
last = S;
|
||||||
@ -134,12 +138,20 @@ bool FDSE::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
|
|
||||||
/// handleFreeWithNonTrivialDependency - Handle frees of entire structures whose
|
/// handleFreeWithNonTrivialDependency - Handle frees of entire structures whose
|
||||||
/// dependency is a store to a field of that structure
|
/// dependency is a store to a field of that structure
|
||||||
bool FDSE::handleFreeWithNonTrivialDependency(FreeInst* F, StoreInst* dependency,
|
bool FDSE::handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dep,
|
||||||
SetVector<Instruction*>& possiblyDead) {
|
SetVector<Instruction*>& possiblyDead) {
|
||||||
TargetData &TD = getAnalysis<TargetData>();
|
TargetData &TD = getAnalysis<TargetData>();
|
||||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||||
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
|
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
|
||||||
|
|
||||||
|
if (dep == MemoryDependenceAnalysis::None ||
|
||||||
|
dep == MemoryDependenceAnalysis::NonLocal)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
StoreInst* dependency = dyn_cast<StoreInst>(dep);
|
||||||
|
if (!dependency)
|
||||||
|
return false;
|
||||||
|
|
||||||
Value* depPointer = dependency->getPointerOperand();
|
Value* depPointer = dependency->getPointerOperand();
|
||||||
unsigned depPointerSize = TD.getTypeSize(dependency->getOperand(0)->getType());
|
unsigned depPointerSize = TD.getTypeSize(dependency->getOperand(0)->getType());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user