Jim Grosbach
2014-Aug-07 21:49 UTC
[LLVMdev] Prevent clang from replacing code with library calls
> On Aug 7, 2014, at 4:12 AM, Anton Korobeynikov <anton at korobeynikov.info> wrote: > >> I downloaded the latest NDK (r10) and compiled with the following cmd: >> arm-linux-androideabi-clang myMemcpy.c -S -fno-builtin -o0 >> It still produces assembly with a call to "memcpy". Maybe the -fno-builtin >> is broken also in the latest release. > It's not broken. Even freestanding implementation is supposed to > provide mem* functions. >It’s also supposed to be possible to write a memcpy() implementation in C without the compiler’s idiom recognizer just transforming it into a call to the system memcpy(). -fno-builtin is supposed to be how to do that, right? -jim
Sean Silva
2014-Aug-07 22:49 UTC
[LLVMdev] Prevent clang from replacing code with library calls
On Thu, Aug 7, 2014 at 2:49 PM, Jim Grosbach <grosbach at apple.com> wrote:> > > On Aug 7, 2014, at 4:12 AM, Anton Korobeynikov <anton at korobeynikov.info> > wrote: > > > >> I downloaded the latest NDK (r10) and compiled with the following cmd: > >> arm-linux-androideabi-clang myMemcpy.c -S -fno-builtin -o0 > >> It still produces assembly with a call to "memcpy". Maybe the > -fno-builtin > >> is broken also in the latest release. > > It's not broken. Even freestanding implementation is supposed to > > provide mem* functions. > > > > It’s also supposed to be possible to write a memcpy() implementation in C > without the compiler’s idiom recognizer just transforming it into a call to > the system memcpy(). -fno-builtin is supposed to be how to do that, right? >IIRC -ffreestanding might be the solution. -- Sean Silva> > -jim > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140807/3a7791e0/attachment.html>
David Sela
2014-Aug-10 13:49 UTC
[LLVMdev] Prevent clang from replacing code with library calls
Its seems like a syntax bug in clang. You must use optimization flag together with the *no-builtin* flag. The following command produces assembly *with* a call to memcopy: arm-linux-androideabi-clang -S myMemcpy.c -fno-builtin The following command produces assembly *without* a call to memcopy: arm-linux-androideabi-clang -S myMemcpy.c -fno-builtin -O1 The *no-builtin* flag is coupled with the optimization flag. Thanks, David On Fri, Aug 8, 2014 at 1:49 AM, Sean Silva <chisophugis at gmail.com> wrote:> > > > On Thu, Aug 7, 2014 at 2:49 PM, Jim Grosbach <grosbach at apple.com> wrote: > >> >> > On Aug 7, 2014, at 4:12 AM, Anton Korobeynikov <anton at korobeynikov.info> >> wrote: >> > >> >> I downloaded the latest NDK (r10) and compiled with the following cmd: >> >> arm-linux-androideabi-clang myMemcpy.c -S -fno-builtin -o0 >> >> It still produces assembly with a call to "memcpy". Maybe the >> -fno-builtin >> >> is broken also in the latest release. >> > It's not broken. Even freestanding implementation is supposed to >> > provide mem* functions. >> > >> >> It’s also supposed to be possible to write a memcpy() implementation in C >> without the compiler’s idiom recognizer just transforming it into a call to >> the system memcpy(). -fno-builtin is supposed to be how to do that, right? >> > > IIRC -ffreestanding might be the solution. > > -- Sean Silva > > >> >> -jim >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140810/81ad7ad3/attachment.html>