[LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?

Duncan Sands baldrick at free.fr
Sun May 9 21:30:40 PDT 2010


Hi Hao Shen,

> I am using llvm-gcc --emit-llvm to generate byte code. With llvm
> readable ll format, I found some standard C library function such as
> llvm.memset.

this is not a C library function, it is an LLVM intrinsic.  An intrinsic is
analogous to a builtin in gcc.  An intrinsic may be expanded out into a code
sequence by the compiler, or may get turned into a library call (which sounds
like is what you are seeing).

> In fact, I'm trying to compile newlibc with llvm, I do not need this
> kind of llvm functions. How can I remove them during the compilation?

You can't avoid them.  The same problem exists with gcc: you can't always
avoid having gcc use the gcc memset builtin.  However it has to be said
that gcc generates its memset builtin less often than llvm-gcc generates
llvm.memset, so this is not as visible.  Also (I'm not sure about this)
it may be that on some platforms gcc always expands builtin_memset into a
code sequence rather than generating a call to the library memset function.
However, gcc is not obliged to use a code sequence even in a freestanding
environment.  The environment is always required to provide memset.  Here's
what the gcc docs say:

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

Ciao,

Duncan.



More information about the llvm-dev mailing list