[DSE] Don't DSE stores that subsequent memmove calls read from
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 20 Feb 2018 23:19:34 +0000 (23:19 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 20 Feb 2018 23:19:34 +0000 (23:19 +0000)
commit737fa40ffad15482801cc60271aed40dd5de9c95
tree66826396d645129f6ea4426e8ea4826f3985a9ef
parent6cd4861c22ef078c2a043ac6ffb1a4467dd85534
[DSE] Don't DSE stores that subsequent memmove calls read from

Summary:
We used to remove the first memmove in cases like this:

  memmove(p, p+2, 8);
  memmove(p, p+2, 8);

which is incorrect.  Fix this by changing isPossibleSelfRead to what was most
likely the intended behavior.

Historical note: the buggy code was added in https://reviews.llvm.org/rL120974
to address PR8728.

Reviewers: rsmith

Subscribers: mcrosier, llvm-commits, jlebar

Differential Revision: https://reviews.llvm.org/D43425

llvm-svn: 325641
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/simple.ll