Re: [PATCH v-1] x86_64: new and improved memset() + question

From: Alexey Dobriyan
Date: Mon Feb 11 2019 - 12:10:46 EST


On Mon, Feb 11, 2019 at 01:47:16PM +0100, Ingo Molnar wrote:
> * Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:

> > QUESTION: is it possible to tell gcc "this function is semantically
> > equivalent to memset(3) so make high level optimizations but call it
> > when it is necessary"? I suspect the answer is "no" :-\
>
> No idea ...
>
> > TODO:
> > CONFIG_FORTIFY_SOURCE is enabled by distros
> > benchmarks
> > testing
> > more comments
> > check with memset_io() so that no surprises pop up
>
> I'd only like to make happy noises here to make sure you continue with
> this work - it does look promising. :-)

Thanks, Ingo.

This is really the core of the problem: once memset() becomes something
other than

static inline void *memset(void *p, int c, size_t len)
{
return __builtin_memset(p, c, len);
}

GCC starts pretending that it doesn't know what memset() is and all those
advertised space savings go to hell.