[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:16:37 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:

This line of code is already predicted to change 2-3 more times in followup PRs, so I'd like to keep the pedantry here to make sure it doesn't get updated wrong, or to force the reviewer to re-discover this bullet point every time

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


More information about the llvm-commits mailing list