fix a few old bugs (found by inspection) where we would zap instructions
authorChris Lattner <sabre@nondot.org>
Sun, 9 Jan 2011 19:26:10 +0000 (19:26 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 9 Jan 2011 19:26:10 +0000 (19:26 +0000)
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

lib/Transforms/Scalar/MemCpyOptimizer.cpp

index 102eab65f2f6661f39a6d1822ec3f59d96f3b9a5..0d3c5c7bdc985bcc29fb421b7ecba750ee1063a5 100644 (file)
@@ -385,7 +385,8 @@ Instruction *MemCpyOpt::tryMergingIntoMemset(Instruction *StartInst,
       
       // 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 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) {
         if (changed) {
           MD->removeInstruction(SI);
           SI->eraseFromParent();
+          MD->removeInstruction(LI);
           LI->eraseFromParent();
           ++NumMemCpyInstr;
           return true;
@@ -786,6 +788,7 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
   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;
     }