From 12cb36c11564e2a7cf85b4b29bddab5c5fd63cf5 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Sun, 1 Jun 2008 21:52:16 +0000 Subject: [PATCH] Don't remove the memcpy when call slot substitution fails. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51848 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/MemCpyOptimizer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 22a00ba3d3e..c599928d82e 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -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();