Harel Cain
2011-Feb-10 07:36 UTC
[LLVMdev] Preventing C backend from using gcc builtin functions
Hi all, Working with llvm 2.8 installed on Mac OS, when using the llvm-gcc frontend and the C backend I see it converting regular (non-checking) memcpy and memset calls to __memset_chk and __memcpy_chk already at the IR stage. Then in the CBE output these are retained as gcc builtin functions. In a similar manner, llvm.objectsize.* calls are replaced with __builtin_object_size calls, another gcc builtin function. This way the resulting C code is usable as-is only on gcc-compatible compilers. Is there a way, either by passing some flags to the llvm-gcc frontend, or by specifying some other flag to llc, to prevent this from happening? Your help is as always much appreciated, Harel Cain -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110210/162dd833/attachment.html>
Anton Korobeynikov
2011-Feb-10 08:16 UTC
[LLVMdev] Preventing C backend from using gcc builtin functions
> Working with llvm 2.8 installed on Mac OS, when using the llvm-gcc frontend > and the C backend I see it converting regular (non-checking) memcpy and > memset calls to __memset_chk and __memcpy_chk already at the IR stage.Most probably these are changed due to defines in the system headers, so, compiler cannot do anything about this. You can hack on your system headers though.> In a similar manner, llvm.objectsize.* calls are replaced with > __builtin_object_size calls, another gcc builtin function.What should be used instead?> Is there a way, either by passing some flags to the llvm-gcc frontend, or by > specifying some other flag to llc, to prevent this from happening?CBE relies on many gcc extensions, so, I doubt fixing this small issue will change the overall situation. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Eric Christopher
2011-Feb-10 09:09 UTC
[LLVMdev] Preventing C backend from using gcc builtin functions
On Feb 10, 2011, at 12:16 AM, Anton Korobeynikov wrote:>> Working with llvm 2.8 installed on Mac OS, when using the llvm-gcc frontend >> and the C backend I see it converting regular (non-checking) memcpy and >> memset calls to __memset_chk and __memcpy_chk already at the IR stage. > Most probably these are changed due to defines in the system headers, > so, compiler cannot do anything about this. > You can hack on your system headers though. > >> In a similar manner, llvm.objectsize.* calls are replaced with >> __builtin_object_size calls, another gcc builtin function. > What should be used instead?For these two sets of things in particular you can pass -D_FORTIFY_SOURCE=0 on your command line. In general, you probably don't want to though. -eric
Apparently Analagous Threads
- [LLVMdev] Preventing C backend from using gcc builtin functions
- RFC: Allowing @llvm.objectsize to be more conservative with null.
- RFC: Allowing @llvm.objectsize to be more conservative with null.
- RFC: Allowing @llvm.objectsize to be more conservative with null.
- Question about __builtin_object_size