[llvm-commits] [llvm] r56885 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Su

Bill Wendling isanbard at gmail.com
Tue Sep 30 15:28:24 PDT 2008


On Tue, Sep 30, 2008 at 3:22 PM, Bill Wendling <isanbard at gmail.com> wrote:
> On Tue, Sep 30, 2008 at 3:17 PM, Evan Cheng <evan.cheng at apple.com> wrote:
>>
>> On Sep 30, 2008, at 2:52 PM, Bill Wendling wrote:
>>
>>> On Tue, Sep 30, 2008 at 2:47 PM, Dan Gohman <gohman at apple.com> wrote:
>>>>
>>>> On Sep 30, 2008, at 2:22 PM, Bill Wendling wrote:
>>>>
>>>>> Author: void
>>>>> Date: Tue Sep 30 16:22:07 2008
>>>>> New Revision: 56885
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=56885&view=rev
>>>>> Log:
>>>>> Add the new `-no-builtin' flag. This flag is meant to mimic the GCC
>>>>> `-fno-builtin' flag. Currently, it's used to replace "memset" with
>>>>> "_bzero"
>>>>> instead of "__bzero" on Darwin10+. This arguably violates the
>>>>> meaning of this
>>>>> flag, but is currently sufficient. The meaning of this flag should
>>>>> become more
>>>>> specific over time.
>>>>
>>>> First, -fno-builtin is only intended to apply to user calls. It is
>>>> not
>>>> intended to apply to libcalls that the compiler generates. For
>>>> example,
>>>> specifying -fno-builtin-memcpy does not tell the compiler not to
>>>> generate calls to memcpy.
>>>>
>>>> Second, it looks like there is confusion about the leading
>>>> underscores.
>>>> The previous code used "__bzero" on Darwin 10, which is actually
>>>> printed as "___bzero" because of Darwin ABI rules. By introducing new
>>>> code that uses "_bzero", it will be printed as "__bzero" on Darwin,
>>>> which doesn't seem to be what was intended here.
>>>>
>>> That's what was intended.
>>>
>>>> And furthermore, if "bzero" was intended, meaning printing in the
>>>> output as "_bzero" on Darwin, that's an even more flagrant abuse of
>>>> the -fno-builtin flag.  -fno-builtin doesn't mean that the compiler
>>>> can
>>>> call functions with names in the user namespace not reserved by the C
>>>> standard.
>>>>
>>> I would have loved to do that, but people had problems with it.
>>
>> I am confused by the meaning of -fno-builtin:
>>        -fno-builtin
>>        -fno-builtin-function
>>            Don't recognize built-in functions that do not begin with
>>            __builtin_ as prefix.
>>
>> Does this actually disable the optimization of memset to bzero?
>>
> That's my reading of it, yes.
>In particular:

-fno-builtin
-fno-builtin-function

...

GCC normally generates special code to handle certain built-in functions
more efficiently; for instance, calls to alloca may become single
instructions that adjust the stack directly, and calls to memcpy may become
inline copy loops. The resulting code is often both smaller and faster, but
since the function calls no longer appear as such, you cannot set a
breakpoint on those calls, nor can you change the behavior of the functions
by linking with a different library.

-bw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080930/69bb194c/attachment.html>


More information about the llvm-commits mailing list