Function attribute for optimization level
David Chisnall
theraven at FreeBSD.org
Tue Jun 6 08:18:47 UTC 2017
On 5 Jun 2017, at 20:57, Jilles Tjoelker <jilles at stack.nl> wrote:
>
> I would prefer using -ffreestanding or -fno-builtin only for the files
> which need it. For example, builtin memcpy() with a small constant size
> is useful to read and write data regardless of alignment and type-based
> aliasing restrictions. If the memcpy() becomes an external call, both
> code size and speed will be affected and the programmer will probably
> choose some other way such as unsafe pointer casts or reading one byte
> at a time.
In a non-freestanding environment, memcpy, memset, and memcmp calls are both translated early to LLVM intrinsics and then have special handling throughout the optimisation pipeline and in code generation. We’re likely to pay a noticeable penalty in code size and performance if we don’t allow the compiler to do these, above and beyond the cost of the call.
David
More information about the freebsd-hackers
mailing list