mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-19 01:34:32 +00:00
two improvements to RemoveAccessedObjects:
1. if the underlying pointer passed in can be resolved to any argument or alloca, then we don't need to scan. Previously we would only avoid the scan if the alloca or byval was actually considered dead. 2. The dead store processing code is itself completely dead and didn't handle volatile stores right anyway, so delete it. This allows simplifying the interface to RemoveAccessedObjects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120467 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6bac79deb3
commit
42cb684f8d
@ -64,8 +64,7 @@ namespace {
|
|||||||
bool runOnBasicBlock(BasicBlock &BB);
|
bool runOnBasicBlock(BasicBlock &BB);
|
||||||
bool HandleFree(CallInst *F);
|
bool HandleFree(CallInst *F);
|
||||||
bool handleEndBlock(BasicBlock &BB);
|
bool handleEndBlock(BasicBlock &BB);
|
||||||
bool RemoveAccessedObjects(Value *Ptr, uint64_t killPointerSize,
|
void RemoveAccessedObjects(Value *Ptr, uint64_t killPointerSize,
|
||||||
BasicBlock::iterator &BBI,
|
|
||||||
SmallPtrSet<Value*, 16> &deadPointers);
|
SmallPtrSet<Value*, 16> &deadPointers);
|
||||||
void DeleteDeadInstruction(Instruction *I,
|
void DeleteDeadInstruction(Instruction *I,
|
||||||
SmallPtrSet<Value*, 16> *deadPointers = 0);
|
SmallPtrSet<Value*, 16> *deadPointers = 0);
|
||||||
@ -514,8 +513,7 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
|
|||||||
|
|
||||||
// Remove any allocas from the DeadPointer set that are loaded, as this
|
// Remove any allocas from the DeadPointer set that are loaded, as this
|
||||||
// makes any stores above the access live.
|
// makes any stores above the access live.
|
||||||
MadeChange |= RemoveAccessedObjects(KillPointer, KillPointerSize, BBI,
|
RemoveAccessedObjects(KillPointer, KillPointerSize, DeadStackObjects);
|
||||||
DeadStackObjects);
|
|
||||||
|
|
||||||
// If all of the allocas were clobbered by the access then we're not going
|
// If all of the allocas were clobbered by the access then we're not going
|
||||||
// to find anything else to process.
|
// to find anything else to process.
|
||||||
@ -529,53 +527,34 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
|
|||||||
/// RemoveAccessedObjects - Check to see if the specified location may alias any
|
/// RemoveAccessedObjects - Check to see if the specified location may alias any
|
||||||
/// of the stack objects in the DeadStackObjects set. If so, they become live
|
/// of the stack objects in the DeadStackObjects set. If so, they become live
|
||||||
/// because the location is being loaded.
|
/// because the location is being loaded.
|
||||||
bool DSE::RemoveAccessedObjects(Value *KillPointer, uint64_t KillPointerSize,
|
void DSE::RemoveAccessedObjects(Value *KillPointer, uint64_t KillPointerSize,
|
||||||
BasicBlock::iterator &BBI,
|
|
||||||
SmallPtrSet<Value*, 16> &DeadStackObjects) {
|
SmallPtrSet<Value*, 16> &DeadStackObjects) {
|
||||||
Value *UnderlyingPointer = KillPointer->getUnderlyingObject();
|
Value *UnderlyingPointer = KillPointer->getUnderlyingObject();
|
||||||
|
|
||||||
// A constant can't be in the dead pointer set.
|
// A constant can't be in the dead pointer set.
|
||||||
if (isa<Constant>(UnderlyingPointer))
|
if (isa<Constant>(UnderlyingPointer))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
// If the kill pointer can be easily reduced to an alloca, don't bother doing
|
// If the kill pointer can be easily reduced to an alloca, don't bother doing
|
||||||
// extraneous AA queries.
|
// extraneous AA queries.
|
||||||
if (DeadStackObjects.count(UnderlyingPointer)) {
|
if (isa<AllocaInst>(UnderlyingPointer) || isa<Argument>(UnderlyingPointer)) {
|
||||||
DeadStackObjects.erase(UnderlyingPointer);
|
DeadStackObjects.erase(UnderlyingPointer);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MadeChange = false;
|
|
||||||
SmallVector<Value*, 16> NowLive;
|
SmallVector<Value*, 16> NowLive;
|
||||||
|
|
||||||
for (SmallPtrSet<Value*, 16>::iterator I = DeadStackObjects.begin(),
|
for (SmallPtrSet<Value*, 16>::iterator I = DeadStackObjects.begin(),
|
||||||
E = DeadStackObjects.end(); I != E; ++I) {
|
E = DeadStackObjects.end(); I != E; ++I) {
|
||||||
// See if this pointer could alias it
|
// See if this pointer could alias it
|
||||||
AliasAnalysis::AliasResult A = AA->alias(*I, getPointerSize(*I, *AA),
|
AliasAnalysis::AliasResult A = AA->alias(*I, getPointerSize(*I, *AA),
|
||||||
KillPointer, KillPointerSize);
|
KillPointer, KillPointerSize);
|
||||||
|
if (A != AliasAnalysis::NoAlias)
|
||||||
// If it must-alias and a store, we can delete it
|
|
||||||
if (isa<StoreInst>(BBI) && A == AliasAnalysis::MustAlias) {
|
|
||||||
StoreInst *S = cast<StoreInst>(BBI);
|
|
||||||
|
|
||||||
// Remove it!
|
|
||||||
++BBI;
|
|
||||||
DeleteDeadInstruction(S, &DeadStackObjects);
|
|
||||||
++NumFastStores;
|
|
||||||
MadeChange = true;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Otherwise, it is undead
|
|
||||||
} else if (A != AliasAnalysis::NoAlias)
|
|
||||||
NowLive.push_back(*I);
|
NowLive.push_back(*I);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SmallVector<Value*, 16>::iterator I = NowLive.begin(), E = NowLive.end();
|
for (SmallVector<Value*, 16>::iterator I = NowLive.begin(), E = NowLive.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
DeadStackObjects.erase(*I);
|
DeadStackObjects.erase(*I);
|
||||||
|
|
||||||
return MadeChange;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DeleteDeadInstruction - Delete this instruction. Before we do, go through
|
/// DeleteDeadInstruction - Delete this instruction. Before we do, go through
|
||||||
|
Loading…
Reference in New Issue
Block a user