fix a few old bugs (found by inspection) where we would zap instructions
without informing memdep. This could cause nondeterminstic weirdness
based on where instructions happen to get allocated, and will hopefully
breath some life into some broken testers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123124 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 102eab6..0d3c5c7 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -385,7 +385,8 @@
// Check to see if this store is to a constant offset from the start ptr.
int64_t Offset;
- if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(), Offset, *TD))
+ if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(),
+ Offset, *TD))
break;
Ranges.addStore(Offset, NextStore);
@@ -490,6 +491,7 @@
if (changed) {
MD->removeInstruction(SI);
SI->eraseFromParent();
+ MD->removeInstruction(LI);
LI->eraseFromParent();
++NumMemCpyInstr;
return true;
@@ -786,6 +788,7 @@
if (CallInst *C = dyn_cast<CallInst>(DepInfo.getInst())) {
if (performCallSlotOptzn(M, M->getDest(), M->getSource(),
CopySize->getZExtValue(), C)) {
+ MD->removeInstruction(M);
M->eraseFromParent();
return true;
}