[llvm] [MemCpyOpt] Don't perform stack-move opt for out-of-bounds copy (PR #217607)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 05:30:09 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)
----------------
dtcxzyw wrote:
IIRC `*SrcOffset + Size` is interpreted as `int64_t + uint64_t`, so it never overflows, right?
https://github.com/llvm/llvm-project/pull/217607
More information about the llvm-commits
mailing list