Reapply "[MemCpyOpt] support offset slices for performStackMoveOptzn and processMemCpy" (#180002)
In particular, support offset of src, since offset of dest will be a
followup change when dest is allowed to be not full-sized with copy.
Extracted from https://github.com/llvm/llvm-project/pull/150792
The miscomputation in the original version was due to incorrect
checking for ModRef, causing incorrect elimination of temporary
buffers: When checking for clobbering stores in performStackMoveOptzn,
use SrcPtr instead of SrcAlloca for the MemoryLocation. When SrcPtr is
offset into the alloca, but DstPtr is still not offset, we need to
check the actual copied region [SrcPtr, SrcPtr+Size) rather than
[SrcAlloca, SrcAlloca+Size) for ModRef. This check can become more
complex once DstOffset is non-zero or not-full-sized, as indicated in
the code comments.
Fixes https://github.com/llvm/llvm-project/issues/177185
Reverts https://github.com/llvm/llvm-project/pull/177482
Relands https://github.com/llvm/llvm-project/pull/176436
Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com>