diff options
| author | Dan Gohman <gohman@apple.com> | 2010-12-16 02:51:19 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-12-16 02:51:19 +0000 |
| commit | e1a17a3473e86bbad4badd2a26b12326cbbe2307 (patch) | |
| tree | d92941d3f369560603bcefb324e6f066be2d8697 /llvm/lib/Transforms | |
| parent | 13eb0eaea7351ba46584d6a86a7fc572e941dcae (diff) | |
| download | bcm5719-llvm-e1a17a3473e86bbad4badd2a26b12326cbbe2307.tar.gz bcm5719-llvm-e1a17a3473e86bbad4badd2a26b12326cbbe2307.zip | |
Make memcpyopt TBAA-aware.
llvm-svn: 121944
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 4c487e0a345..a92e848b845 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -688,10 +688,6 @@ bool MemCpyOpt::processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep, ConstantInt *C1 = dyn_cast<ConstantInt>(MDep->getLength()); if (!C1) return false; - uint64_t DepSize = C1->getValue().getZExtValue(); - if (DepSize < MSize) - return false; - AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); // Verify that the copied-from memory doesn't change in between the two @@ -716,7 +712,8 @@ bool MemCpyOpt::processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep, // source and dest might overlap. We still want to eliminate the intermediate // value, but we have to generate a memmove instead of memcpy. Intrinsic::ID ResultFn = Intrinsic::memcpy; - if (!AA.isNoAlias(M->getRawDest(), MSize, MDep->getRawSource(), DepSize)) + if (AA.alias(AA.getLocationForDest(M), AA.getLocationForSource(MDep)) != + AliasAnalysis::NoAlias) ResultFn = Intrinsic::memmove; // If all checks passed, then we can transform M. @@ -795,14 +792,9 @@ bool MemCpyOpt::processMemCpy(MemCpyInst *M) { bool MemCpyOpt::processMemMove(MemMoveInst *M) { AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); - // If the memmove is a constant size, use it for the alias query, this allows - // us to optimize things like: memmove(P, P+64, 64); - uint64_t MemMoveSize = AliasAnalysis::UnknownSize; - if (ConstantInt *Len = dyn_cast<ConstantInt>(M->getLength())) - MemMoveSize = Len->getZExtValue(); - // See if the pointers alias. - if (AA.alias(M->getRawDest(), MemMoveSize, M->getRawSource(), MemMoveSize) != + if (AA.alias(AA.getLocationForDest(M), + AA.getLocationForSource(M)) != AliasAnalysis::NoAlias) return false; |

