[llvm] [MemCpyOpt] support offset slices for performStackMoveOptzn and processMemCpy (PR #176436)

Jameson Nash via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 05:33:05 PST 2026


================
@@ -1497,35 +1494,60 @@ bool MemCpyOptPass::performMemCpyToMemSetOptzn(MemCpyInst *MemCpy,
 // transformation only because we restrict the scope of this optimization to
 // allocas that aren't captured.
 bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
-                                          AllocaInst *DestAlloca,
-                                          AllocaInst *SrcAlloca, TypeSize Size,
-                                          BatchAAResults &BAA) {
+                                          Value *DestPtr, Value *SrcPtr,
+                                          TypeSize Size, BatchAAResults &BAA) {
   LLVM_DEBUG(dbgs() << "Stack Move: Attempting to optimize:\n"
                     << *Store << "\n");
 
+  AllocaInst *DestAlloca = dyn_cast<AllocaInst>(getUnderlyingObject(DestPtr));
+  if (!DestAlloca)
+    return false;
+
+  AllocaInst *SrcAlloca = dyn_cast<AllocaInst>(getUnderlyingObject(SrcPtr));
----------------
vtjnash wrote:

That is essentially the same as disabling the optimization, since that forces SrcOffset == 0

(I'm also on discord if I can be of further use)

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


More information about the llvm-commits mailing list