[llvm-dev] How to remove memcpy

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Sat Oct 15 16:17:44 PDT 2016


On Sat, Oct 15, 2016 at 04:12:15PM -0700, Flamedoge wrote:
> Even with -ffreestanding LLVM generates memcpy/memset? Does this mean some
> passes do not honor this flag? If you really wanted to prevent libcalls,
> you could technically translate those memcpy/memset to loops in lowering.
> Kevin

Yes, LLVM follows the same rules as GCC here:

  GCC requires the freestanding environment provide `memcpy', `memmove',
  `memset' and `memcmp'.

As I said, target lowering may decide to inline all the llvm.mem*
intrinsics, but it is typically wasteful to do so. Exceptions are e.g.
on x86 when optimising for size, since the function call overhead is
large than the "rep stosb" sequence would be for memset or "rep movsb"
or memcpy.

Joerg


More information about the llvm-dev mailing list