SHEN Hao
2010-May-03 16:12 UTC
[LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
Hi, all, 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. 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? Best regards, -- Hao Shen
Duncan Sands
2010-May-10 04:30 UTC
[LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
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.
SHEN Hao
2010-May-10 15:18 UTC
[LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
Thanks a lot for your answer. As what you said, I can not have any options to avoid generating this kind of intrinsic for byte code. Is it possible to modify gcc and ask it take all memset liked functions as a general function call? I know this solution is less performance efficient, but I would like to have it for my llvm assembly level modification works. But anyway, thanks for you help. Hao On Mon, May 10, 2010 at 6:30 AM, Duncan Sands <baldrick at free.fr> wrote:> 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. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hao Shen
Apparently Analagous Threads
- [LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
- [LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
- [LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
- [LLVMdev] How can I remove Intrinsic Functions during llvm-gcc compilation?
- [LLVMdev] Why function pointer is different from other data type?