forked from OSchip/llvm-project
rename a function and reduce some indentation, no functionality change.
llvm-svn: 120391
This commit is contained in:
parent
936a5b44ee
commit
3590ef817c
|
@ -111,9 +111,9 @@ static bool hasMemoryWrite(Instruction *I) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isElidable - If the value of this instruction and the memory it writes to is
|
/// isRemovable - If the value of this instruction and the memory it writes to
|
||||||
/// unused, may we delete this instrtction?
|
/// is unused, may we delete this instruction?
|
||||||
static bool isElidable(Instruction *I) {
|
static bool isRemovable(Instruction *I) {
|
||||||
assert(hasMemoryWrite(I));
|
assert(hasMemoryWrite(I));
|
||||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
|
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
|
||||||
return II->getIntrinsicID() != Intrinsic::lifetime_end;
|
return II->getIntrinsicID() != Intrinsic::lifetime_end;
|
||||||
|
@ -192,6 +192,7 @@ static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2,
|
||||||
|
|
||||||
bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||||
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
||||||
|
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||||
TD = getAnalysisIfAvailable<TargetData>();
|
TD = getAnalysisIfAvailable<TargetData>();
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
@ -238,7 +239,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InstDep.isDef()) {
|
if (!InstDep.isDef()) {
|
||||||
// If this is a may-aliased store that is clobbering the store value, we
|
// If this is a may-aliased store that is clobbering the store value, we
|
||||||
// can keep searching past it for another must-aliased pointer that stores
|
// can keep searching past it for another must-aliased pointer that stores
|
||||||
|
@ -249,7 +250,6 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||||
// we can remove the first store to P even though we don't know if P and Q
|
// we can remove the first store to P even though we don't know if P and Q
|
||||||
// alias.
|
// alias.
|
||||||
if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
|
if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
|
||||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
|
||||||
AliasAnalysis::Location Loc = AA.getLocation(SI);
|
AliasAnalysis::Location Loc = AA.getLocation(SI);
|
||||||
while (InstDep.isClobber() && InstDep.getInst() != &BB.front()) {
|
while (InstDep.isClobber() && InstDep.getInst() != &BB.front()) {
|
||||||
// Can't look past this instruction if it might read 'Loc'.
|
// Can't look past this instruction if it might read 'Loc'.
|
||||||
|
@ -266,19 +266,21 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||||
// long as this store is at least as big as it.
|
// long as this store is at least as big as it.
|
||||||
if (InstDep.isDef() && hasMemoryWrite(InstDep.getInst())) {
|
if (InstDep.isDef() && hasMemoryWrite(InstDep.getInst())) {
|
||||||
Instruction *DepStore = InstDep.getInst();
|
Instruction *DepStore = InstDep.getInst();
|
||||||
if (isStoreAtLeastAsWideAs(Inst, DepStore, TD) && isElidable(DepStore)) {
|
if (!isRemovable(DepStore) ||
|
||||||
// Delete the store and now-dead instructions that feed it.
|
!isStoreAtLeastAsWideAs(Inst, DepStore, TD))
|
||||||
DeleteDeadInstruction(DepStore);
|
|
||||||
++NumFastStores;
|
|
||||||
MadeChange = true;
|
|
||||||
|
|
||||||
// DeleteDeadInstruction can delete the current instruction in loop
|
|
||||||
// cases, reset BBI.
|
|
||||||
BBI = Inst;
|
|
||||||
if (BBI != BB.begin())
|
|
||||||
--BBI;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
// Delete the store and now-dead instructions that feed it.
|
||||||
|
DeleteDeadInstruction(DepStore);
|
||||||
|
++NumFastStores;
|
||||||
|
MadeChange = true;
|
||||||
|
|
||||||
|
// DeleteDeadInstruction can delete the current instruction in loop
|
||||||
|
// cases, reset BBI.
|
||||||
|
BBI = Inst;
|
||||||
|
if (BBI != BB.begin())
|
||||||
|
--BBI;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +303,7 @@ bool DSE::HandleFree(CallInst *F) {
|
||||||
if (Dep.isNonLocal()) return false;
|
if (Dep.isNonLocal()) return false;
|
||||||
|
|
||||||
Instruction *Dependency = Dep.getInst();
|
Instruction *Dependency = Dep.getInst();
|
||||||
if (!hasMemoryWrite(Dependency) || !isElidable(Dependency))
|
if (!hasMemoryWrite(Dependency) || !isRemovable(Dependency))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject();
|
Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject();
|
||||||
|
@ -359,7 +361,7 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
|
||||||
|
|
||||||
// If we find a store whose pointer is dead.
|
// If we find a store whose pointer is dead.
|
||||||
if (hasMemoryWrite(BBI)) {
|
if (hasMemoryWrite(BBI)) {
|
||||||
if (isElidable(BBI)) {
|
if (isRemovable(BBI)) {
|
||||||
// See through pointer-to-pointer bitcasts
|
// See through pointer-to-pointer bitcasts
|
||||||
Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject();
|
Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue