Re: [RFC PATCH v1 0/5] nolibc x86-64 string functions

From: Willy Tarreau
Date: Wed Aug 30 2023 - 17:34:14 EST


Hi Ammar,

On Wed, Aug 30, 2023 at 08:57:21PM +0700, Ammar Faizi wrote:
> Hi Willy,
>
> This is an RFC patchset for nolibc x86-64 string functions. There are 5
> patches in this series.
>
> ## Patch 1-3: Use `rep movsb`, `rep stosb`, and `rep cmpsb` for:
> - memcpy() and memmove()
> - memset()
> - memcmp()
> respectively. They can simplify the generated ASM code.
>
> Patch 4 and 5 are not related, just a small cleanup.

So overall I'm fine with this, I think it's reasonable. As you said
we're not trying to chase the very last byte, but for such functions
it's also nice if they can remain small. Some of them might even
benefit from being inlined by the way (in this case they'd rather
move to C functions with an asm() statement), because the call
instruction and the register moves or spilling code will generally
be larger than the functions themselves. That might be worth checking.
Ah no, we cannot because some of them are called from libgcc and friends.
Or we may need to mark them inline and weak without static, I'm not sure
how well that works.

Please just let me know if you intend to change a few things based on
previous comments, and also this memcmp() stuff that's both C and asm.

Thanks!
Willy