[PATCH] D101510: Do not merge memcpy if the first source is a parameter of coroutine function

Xun Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 18:48:25 PDT 2021


lxfind created this revision.
lxfind added reviewers: nikic, asbirlea.
Herald added subscribers: ChuanqiXu, hoy, modimo, wenlei, hiraditya.
lxfind requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a temporary walkaround of https://bugs.llvm.org/show_bug.cgi?id=48857.
MemCpyOpt is able to merge two memcpy intrinsics, if the destination of the first memcpy is the same as the source of the second, and there are no changes to the values.
If the first memcpy's source is a parameter of a coroutine function, unfortunately this optimization will not work.
Parameters of a coroutine function, despiite marked as readonly (for rvalues), may be destroyed when the coroutine is suspended.
If the second memcpy happens after coroutine suspension, the parameter may have died already and we cannot copy from it at that point.
Hence if the source of the first memcpy is a parameter, we don't merge memcpys.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101510

Files:
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
  llvm/test/Transforms/MemCpyOpt/coroutine-params.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101510.341383.patch
Type: text/x-patch
Size: 8962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/fd02865a/attachment-0001.bin>


More information about the llvm-commits mailing list