summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-01-21 22:07:57 +0000
committerDan Gohman <gohman@apple.com>2011-01-21 22:07:57 +0000
commit19e30d5a7d3369feae36cbe7f4f4c1f358881c41 (patch)
treec15365999dfb60409b2fda719e69bf5322cb3cdd /llvm/lib/Transforms
parent6da4ca83b07cb79dabb6243d6ccea5cae1dbd8ae (diff)
downloadbcm5719-llvm-19e30d5a7d3369feae36cbe7f4f4c1f358881c41.tar.gz
bcm5719-llvm-19e30d5a7d3369feae36cbe7f4f4c1f358881c41.zip
Actually check memcpy lengths, instead of just commenting about
how they should be checked. llvm-svn: 123999
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 0d3c5c7bdc9..acddf0878b0 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -690,8 +690,10 @@ bool MemCpyOpt::processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep,
// 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());
- if (!C1) return false;
+ ConstantInt *MDepLen = dyn_cast<ConstantInt>(MDep->getLength());
+ ConstantInt *MLen = dyn_cast<ConstantInt>(M->getLength());
+ if (!MDepLen || !MLen || MDepLen->getZExtValue() < MLen->getZExtValue())
+ return false;
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
OpenPOWER on IntegriCloud