[MemCpyOpt] Don't move the memset when optimizing memset+memcpy.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 20 May 2015 23:55:16 +0000 (23:55 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 20 May 2015 23:55:16 +0000 (23:55 +0000)
commit6d1485e974dfdcf23ba302595e069d9eecbb8162
treecd74c430f7f1db369fbb07c89bf20119624acc52
parent008a1efecf4bc7f142dda936f79783c69524776e
[MemCpyOpt] Don't move the memset when optimizing memset+memcpy.

Fixes PR23599, another miscompile introduced by r235232: when there is
another dependency on the destination of the created memset (i.e., the
part of the original destination that the memcpy doesn't depend on)
between the memcpy and the original memset, we would insert the created
memset after the memcpy, and thus after the other dependency.

Instead, insert the created memset right after the old one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237858 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/MemCpyOptimizer.cpp
test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll