Don't remove the memcpy when call slot substitution fails.
authorOwen Anderson <resistor@mac.com>
Sun, 1 Jun 2008 21:52:16 +0000 (21:52 +0000)
committerOwen Anderson <resistor@mac.com>
Sun, 1 Jun 2008 21:52:16 +0000 (21:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51848 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/MemCpyOptimizer.cpp

index 22a00ba3d3ea6e2bc70d155770bcae071f79dc6b..c599928d82e0c60384514393d56c1b2fac61410a 100644 (file)
@@ -580,14 +580,19 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
     return false;
 
   // All the checks have passed, so do the transformation.
+  bool changedArgument = false;
   for (unsigned i = 0; i < CS.arg_size(); ++i)
     if (CS.getArgument(i) == cpySrc) {
       if (cpySrc->getType() != cpyDest->getType())
         cpyDest = CastInst::CreatePointerCast(cpyDest, cpySrc->getType(),
                                               cpyDest->getName(), C);
+      changedArgument = true;
       CS.setArgument(i, cpyDest);
     }
 
+  if (!changedArgument)
+    return false;
+
   // Drop any cached information about the call, because we may have changed
   // its dependence information by changing its parameter.
   MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();