fix a latent bug in memcpyoptimizer that my recent patches exposed: it wasn't
authorChris Lattner <sabre@nondot.org>
Sat, 8 Jan 2011 22:19:21 +0000 (22:19 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Jan 2011 22:19:21 +0000 (22:19 +0000)
updating memdep when fusing stores together.  This fixes the crash optimizing
the bullet benchmark.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123091 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/MemCpyOptimizer.cpp

index 76fab1cd281afd74e297f06a1c30dcaef30b73b2..102eab65f2f6661f39a6d1822ec3f59d96f3b9a5 100644 (file)
@@ -456,8 +456,10 @@ Instruction *MemCpyOpt::tryMergingIntoMemset(Instruction *StartInst,
     // Zap all the stores.
     for (SmallVector<Instruction*, 16>::const_iterator
          SI = Range.TheStores.begin(),
-         SE = Range.TheStores.end(); SI != SE; ++SI)
+         SE = Range.TheStores.end(); SI != SE; ++SI) {
+      MD->removeInstruction(*SI);
       (*SI)->eraseFromParent();
+    }
     ++NumMemSetInfer;
   }
   
@@ -912,7 +914,7 @@ bool MemCpyOpt::iterateOnFunction(Function &F) {
 
       // Reprocess the instruction if desired.
       if (RepeatInstruction) {
-        --BI;
+        if (BI != BB->begin()) --BI;
         MadeChange = true;
       }
     }