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 | 387f28aff41bae6a81311279b203a1281eaa443a (patch) | |
tree | d2c63b30ae9175f22baaea33a98c5f1f4875ae68 /lib/Transforms/Scalar/MemCpyOptimizer.cpp | |
parent | ad3ea3d85f164dc1b2746950e378334197d8688d (diff) |
Make memcpyopt TBAA-aware.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/MemCpyOptimizer.cpp')
-rw-r--r-- | lib/Transforms/Scalar/MemCpyOptimizer.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 4c487e0a34..a92e848b84 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/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; |