On Mon, Dec 5, 2022 at 3:12 PM Marco Elver wrote: > On Mon, 5 Dec 2022 at 14:26, Alexander Potapenko > wrote: > > > > Recent Clang changes may cause it to delete calls of memcpy(), if the > > source is an uninitialized volatile local. > > This happens because passing a pointer to a volatile local into memcpy() > > discards the volatile qualifier, giving the compiler a free hand to > > optimize the memcpy() call away. > > > > To outsmart the compiler, we call __msan_memcpy() instead of memcpy() > > in test_memcpy_aligned_to_aligned(), test_memcpy_aligned_to_unaligned() > > and test_memcpy_aligned_to_unaligned2(), because it's the behavior of > > __msan_memcpy() we are testing here anyway. > > > > Signed-off-by: Alexander Potapenko > > It might be nice to retain memcpy() calls somehow, as that tests > end-to-end that the compiler does the right thing here i.e. replacing > the memcpy() calls with instrumented versions. > > Does OPTIMIZER_HIDE_VAR() help? This should prevent the compiler from > seeing it's uninitialized. > > It indeed does, thanks! Let me send a v2.