[llvm] [MemCpyOpt] Don't perform stack-move opt for out-of-bounds copy (PR #217607)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 08:35:43 PDT 2026
================
@@ -1572,6 +1572,13 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
return false;
}
+ if (*SrcOffset) {
+ // Make sure that the copied offset is actually part of the alloca. There
+ // might be an out-of-bounds copy in dead code.
+ if (!Size.isFixed() || *SrcOffset + Size > *SrcSize)
----------------
antoniofrighetto wrote:
I guess you would need to memcpy at least `2^64 - SrcOffset` bytes to make `*SrcOffset + Size` wrap around, which I don't think it should matter in practice (and wouldn't probably reach this code anyways).
https://github.com/llvm/llvm-project/pull/217607
More information about the llvm-commits
mailing list