diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-01-06 23:50:22 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-01-06 23:50:22 +0000 |
commit | 0535003bef40b7a90ff62f933da06cf4ae613994 (patch) | |
tree | 8a21ed072c44f00af29a1a7e659f3b7625b0cf55 /llvm/lib/Transforms | |
parent | 882a8eed3ef400af27a1047edde0f16083bb61bd (diff) | |
download | bcm5719-llvm-0535003bef40b7a90ff62f933da06cf4ae613994.tar.gz bcm5719-llvm-0535003bef40b7a90ff62f933da06cf4ae613994.zip |
Fix PR26051: Memcpy optimization should introduce a call to memcpy before the store destination position
This is a conservative fix, I expect Amaury to relax this.
Follow-up for r256923
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 256999
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 5711a775df8..6b43b0f7a2a 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -529,11 +529,13 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { // We found an instruction that may write to the loaded memory. // We can try to promote at this position instead of the store - // position if nothing alias the store memory after this. + // position if nothing alias the store memory after this and the store + // destination is not in the range. P = &*I; for (; I != E; ++I) { MemoryLocation StoreLoc = MemoryLocation::get(SI); - if (AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) { + if (&*I == SI->getOperand(1) || + AA.getModRefInfo(&*I, StoreLoc) != MRI_NoModRef) { P = nullptr; break; } |