[MemCpyOpt] Check for throwing calls during call slot optimization
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 4 Oct 2020 16:04:28 +0000 (18:04 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 6 Oct 2020 16:24:40 +0000 (18:24 +0200)
commit6b441ca523cd6be9475106408a60989ad1f5ae55
treecafd456963c26233f2631a70532fd15f99524f73
parent80cde02e85df3f1903f0a04ccccaf0f84c2854d1
[MemCpyOpt] Check for throwing calls during call slot optimization

When performing call slot optimization for a non-local destination,
we need to check whether there may be throwing calls between the
call and the copy. Otherwise, the early write to the destination
may be observable by the caller.

This was already done for call slot optimization of load/store,
but not for memcpys. For the sake of clarity, I'm moving this check
into the common optimization function, even if that does need an
additional instruction scan for the load/store case.

As efriedma pointed out, this check is not sufficient due to
potential accesses from another thread. This case is left as a TODO.

Differential Revision: https://reviews.llvm.org/D88799
llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/callslot.ll