processStore may delete the instruction, avoid
authorTorok Edwin <edwintorok@gmail.com>
Sun, 4 May 2008 08:51:25 +0000 (08:51 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Sun, 4 May 2008 08:51:25 +0000 (08:51 +0000)
using dyn_cast<> on already freed memory.

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

lib/Transforms/Scalar/MemCpyOptimizer.cpp

index d6e5f3964bb6944a3f23420a3ddfd15d963001bd..8036bf89d5fe6b193c6857e92be2d9dc65490625 100644 (file)
@@ -718,8 +718,7 @@ bool MemCpyOpt::iterateOnFunction(Function &F) {
       
       if (StoreInst *SI = dyn_cast<StoreInst>(I))
         changed_function |= processStore(SI, BI);
-
-      if (MemCpyInst* M = dyn_cast<MemCpyInst>(I)) {
+      else if (MemCpyInst* M = dyn_cast<MemCpyInst>(I)) {
         changed_function |= processMemCpy(M);
       }
     }