mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
[MemCpyOpt] Look at any dependency -not just source- for memset+memcpy.
This fixes another miscompile introduced by r235232: when there was a dependency on the memcpy destination other than the memset, we would ignore it, because we only looked at the source dependency. It was a mistake to use SrcDepInfo. Instead, just use DepInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237066 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -927,14 +927,12 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
|
||||
return true;
|
||||
}
|
||||
|
||||
AliasAnalysis::Location SrcLoc = AliasAnalysis::getLocationForSource(M);
|
||||
MemDepResult SrcDepInfo = MD->getPointerDependencyFrom(SrcLoc, true,
|
||||
M, M->getParent());
|
||||
MemDepResult DepInfo = MD->getDependency(M);
|
||||
|
||||
// Try to turn a partially redundant memset + memcpy into
|
||||
// memcpy + smaller memset. We don't need the memcpy size for this.
|
||||
if (SrcDepInfo.isClobber())
|
||||
if (MemSetInst *MDep = dyn_cast<MemSetInst>(SrcDepInfo.getInst()))
|
||||
if (DepInfo.isClobber())
|
||||
if (MemSetInst *MDep = dyn_cast<MemSetInst>(DepInfo.getInst()))
|
||||
if (processMemSetMemCpyDependence(M, MDep))
|
||||
return true;
|
||||
|
||||
@ -948,7 +946,6 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
|
||||
// c) memcpy from freshly alloca'd space or space that has just started its
|
||||
// lifetime copies undefined data, and we can therefore eliminate the
|
||||
// memcpy in favor of the data that was already at the destination.
|
||||
MemDepResult DepInfo = MD->getDependency(M);
|
||||
if (DepInfo.isClobber()) {
|
||||
if (CallInst *C = dyn_cast<CallInst>(DepInfo.getInst())) {
|
||||
if (performCallSlotOptzn(M, M->getDest(), M->getSource(),
|
||||
@ -961,6 +958,10 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
|
||||
}
|
||||
}
|
||||
|
||||
AliasAnalysis::Location SrcLoc = AliasAnalysis::getLocationForSource(M);
|
||||
MemDepResult SrcDepInfo = MD->getPointerDependencyFrom(SrcLoc, true,
|
||||
M, M->getParent());
|
||||
|
||||
if (SrcDepInfo.isClobber()) {
|
||||
if (MemCpyInst *MDep = dyn_cast<MemCpyInst>(SrcDepInfo.getInst()))
|
||||
return processMemCpyMemCpyDependence(M, MDep, CopySize->getZExtValue());
|
||||
|
Reference in New Issue
Block a user