diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-09 07:39:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-09 07:39:50 +0000 |
commit | f7f35467a9aac818bd5813c17e80d7efb66dadd7 (patch) | |
tree | e6ead159a5d25ccc945d60105a188eaef601c6b1 /lib/Transforms/Scalar/MemCpyOptimizer.cpp | |
parent | d8c0536651af94513b60061f0ea51b948e856374 (diff) |
fix PR8753, eliminating a case where we'd infinitely make a
substitution because it doesn't actually change the IR. Patch by
Jakub Staszak!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/MemCpyOptimizer.cpp')
-rw-r--r-- | lib/Transforms/Scalar/MemCpyOptimizer.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 318e212899..6f93e326ba 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -675,6 +675,14 @@ bool MemCpyOpt::processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep, if (M->getSource() != MDep->getDest() || MDep->isVolatile()) return false; + // If dep instruction is reading from our current input, then it is a noop + // transfer and substituting the input won't change this instruction. Just + // ignore the input and let someone else zap MDep. This handles cases like: + // memcpy(a <- a) + // memcpy(b <- a) + if (M->getSource() == MDep->getSource()) + return false; + // Second, the length of the memcpy's must be the same, or the preceeding one // must be larger than the following one. ConstantInt *C1 = dyn_cast<ConstantInt>(MDep->getLength()); |