[MemCpyOpt] Handle unusual memcpy element type
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 27 Jun 2021 14:19:21 +0000 (16:19 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 27 Jun 2021 14:21:44 +0000 (16:21 +0200)
commitf025053977f330152da081b7060a5d9cba0a9e22
treed261a21cd0109a2aaa087874755644f20a401cb1
parent153da08a6cd7feea6644b3191019573d70a5bbd3
[MemCpyOpt] Handle unusual memcpy element type

Apparently, it is legal to use memcpy/memset with pointer types
other than i8*. Prior to 81fcdae68c5ff656c30032fd26c6a21af4c51dbb
this case was silently miscompiled, as the i8 offset calculation
was performed on some other type. Now it would crash due to a
type mismatch. Fix this by inserting an explicit bitcast to i8*.
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll