Clang automatically inserts llvm.memcpy

Clang automatically inserts llvm.memcpy when we assign (copy) a structure.

input .c file

unsigned char buf1[32];
unsigned char buf2[32];

buf2 = buf1;

output .ll file
call void @llvm.memcpy.p0i8.p0i8.i16(…

We are targeting embedded systems, so we cannot accept this behavior.


  1. Is there a way to prevent this automatic insertion ?
  2. If there is no way to prevent it, which library function other than memcpy will be automatically inserted?

BTW, I tried specifying the “-fno-builtin-memcpy” option, but llvm.memcpy was still auto-inserted.

Thank you.