why pass -1 as length? That make the function be UB?
It would probably also be better to just pass in 2 noalias pointers, rather than allocas. That way the memcpy call won't be removed?
nit: tab? Same below.
LGTM, thanks for also improving the test case!
Yes that looks like a missed optimization that was hidden by the fact that the store got removed because it was to an alloca that was never read! Thank you very much for improving the test so that it exposes this. Not sure what is going on, but it might be good to add a TODO/FIXME comment.