[llvm] Reapply "[MemCpyOpt] support offset slices for performStackMoveOptzn and processMemCpy", with bug fixed (PR #180002)

Jameson Nash via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 06:43:50 PST 2026


================
@@ -1662,8 +1684,16 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
 
   // Check that, from after the Load to the end of the BB,
   //   - if the dest has any Mod, src has no Ref, and
-  //   - if the dest has any Ref, src has no Mod except full-sized lifetimes.
-  MemoryLocation SrcLoc(SrcAlloca, LocationSize::precise(Size));
+  //   - if the dest has any Ref, src has no Mod except full-sized lifetimes
+  // Where:
+  //   - src is defined as the memory from max(SrcAlloca, SrcPtr minus
+  //     dest_offset) to min(dest_size, SrcSize minus SrcOffset)
+  //   - dest_offset and dest_size could be computed by DestModRefCallback
+  //     to be the bounds of the first and last mod region, and which is at
+  //     least as large as DestOffset to DestSize, and at most as large as
+  //     SrcAlloca to SrcSize.
----------------
vtjnash wrote:

The preceding bullet point won't currently be directly implementable (we seem to be unable currently to create a MemoryLocation that is at an offset of a different address), so we will likely want to explain why what we are in fact implementing something different than would be most accurately described in that comment, but that is conservatively correct

https://github.com/llvm/llvm-project/pull/180002


More information about the llvm-commits mailing list