tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Disabling gcc's __builtin_foo() functions



For non-freestanding builds (aka userspace) gcc will automatically
convert calls to some string functions into __builtin_foo() forms
which it then inlines (certainly on i386 and amd64).

This might seem a good idea! but on some archs - especially 64 bit
ones that pass function args in registers (eg amd64 and sparc64) the
functions we have in libc are significantly faster than the inline
code that gcc generates.

Each individual function can be disabled with -f-no-builtin-foo but
that would have to be done on the command line of every gcc invocation.

Also there are some cases where the inlined code will be better
(strlen("xxx") and memcpy for fixed lengths with certain ranges)
so you do want the compiler to know of the functions, just not emit
the code.

For the kernel we enable the builtin forms in src/sys/lib/libkern/libkern.h
(using #defines) since the kernel is compiler 'freestanding' and gcc
won't have enabled them by default.

Thoughts ... ?

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index