[PATCH] D153453: (WIP)[MemCpyOpt] implement stack-move optimization which unify the lifetime overlapped fully copied allocas, the src is never modified or referenced

Kohei Asano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 11:50:13 PDT 2023


khei4 created this revision.
khei4 added a reviewer: nikic.
Herald added subscribers: kmitropoulou, StephenFan, asbirlea, hiraditya.
Herald added a project: All.
khei4 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is takeover from @pcwalton 's https://reviews.llvm.org/D140089

New transformation unifies the two allocates on the same BB if the followings are satisfied
(1) The src is fully copied to dest by memcpy, memmove or store&load.
(2) Two allocas are never captured.
(3) The src has no read and no write, from after the full copy to the end of the BB.
I think (2) is done by CaptureTracking, (3) is done by ModRef check of MemSSA.

Note: I think explicit lifetime intrinsics are not necessary to do this, although removing redundant lifetime intrinsic and inserting it are beneficial.


https://reviews.llvm.org/D153453

Files:
  llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153453.533354.patch
Type: text/x-patch
Size: 4021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230621/8f259abb/attachment.bin>


More information about the llvm-commits mailing list