kernel - Optimize bcopy, bzero, memset
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 23 Sep 2018 22:42:26 +0000 (15:42 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 25 Sep 2018 16:29:09 +0000 (09:29 -0700)
commit7367f28070a36cc8bd2731d3f7fce7067fe3e7d5
tree9faf963ea64199567823849d6484c50535b62abc
parent7f5940c5ea29a2d795a26de6262ad132c49e3ed1
kernel - Optimize bcopy, bzero, memset

* Use __builtin_memset() for bzero() and __builtin_memmove()
  for bcopy().

  - Must use _bcopy in a few places where GCC complains about
    structural punning.  Even casting doesn't help.

  - GCC's __builtin_memset() and __builtin_memmove() has a side
    effect where it assumes that the pointer arguments cannot be
    NULL.  In fact, they can be NULL when the byte count is 0.
    This assumption by GCC causes later unrelated conditionals
    on the pointers against NULL to be improperly optimized-out.

    We had to fix one place where this blew the system up.

* Implement memset() in assembly (remove from libkern).

* Implement memmove() in assembly (remove from libkern).
sys/dev/crypto/safe/safe.c
sys/dev/crypto/ubsec/ubsec.c
sys/kern/subr_bus.c
sys/libkern/memmove.c
sys/libkern/memset.c
sys/net/bpf.c
sys/platform/pc64/x86_64/machdep.c
sys/platform/pc64/x86_64/support.s
sys/platform/pc64/x86_64/trap.c
sys/sys/systm.h