mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Teach basicaa that memset's modref set is at worst "mod" and never
contains "ref". Enhance DSE to use a modref query instead of a store-specific hack to generalize the "ignore may-alias stores" optimization to handle memset and memcpy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120368 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -191,6 +191,7 @@ static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2,
|
||||
I1Size >= I2Size;
|
||||
}
|
||||
|
||||
|
||||
bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
||||
TD = getAnalysisIfAvailable<TargetData>();
|
||||
@@ -239,7 +240,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!InstDep.isDef()) {
|
||||
// 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
|
||||
@@ -250,12 +251,16 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
// we can remove the first store to P even though we don't know if P and Q
|
||||
// alias.
|
||||
if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
|
||||
AliasAnalysis::Location Loc =
|
||||
getAnalysis<AliasAnalysis>().getLocation(SI);
|
||||
while (InstDep.isClobber() && isa<StoreInst>(InstDep.getInst()) &&
|
||||
InstDep.getInst() != &BB.front())
|
||||
InstDep = MD.getPointerDependencyFrom(Loc, false, InstDep.getInst(),
|
||||
&BB);
|
||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||
AliasAnalysis::Location Loc = AA.getLocation(SI);
|
||||
while (InstDep.isClobber() && InstDep.getInst() != &BB.front()) {
|
||||
// Can't look past this instruction if it might read 'Loc'.
|
||||
if (AA.getModRefInfo(InstDep.getInst(), Loc) & AliasAnalysis::Ref)
|
||||
break;
|
||||
|
||||
InstDep = MD.getPointerDependencyFrom(Loc, false,
|
||||
InstDep.getInst(), &BB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user