[llvm] [MemCpyOpt] Extend call slot optimization for non-dereferenceable destinations. (PR #217436)
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 12:45:57 PDT 2026
================
@@ -924,8 +924,18 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad,
ExplicitlyDereferenceableOnly) ||
!isDereferenceablePointer(cpyDest, APInt(64, cpySize),
SimplifyQuery(DL, DT, AC, C))) {
- LLVM_DEBUG(dbgs() << "Call Slot: Dest pointer not dereferenceable\n");
- return false;
+ // If the call is guaranteed to return normally (willreturn + nounwind),
+ // and there are no instructions between the call and the store that might
+ // trap or throw, execution will reach the store. Since the store would
+ // trap anyway if the pointer was not dereferenceable, we can forward the
+ // pointer to the call. Perform optimization only for non-memcpy/memset
+ // calls, as those are special cased later.
----------------
alinas wrote:
Ack, removed the exclusion and updated tests.
https://github.com/llvm/llvm-project/pull/217436
More information about the llvm-commits
mailing list