This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: expected_retval attribute proposal
> > Ideas? If this turns out to be acceptable hack, I will implement the gcc
> > part. (well and glibc part to if neccesary...)
>
> I wouldn't stop you from implementing this idea, but I'd like to see
> some use cases first. I.e. which of the glibc functions should have an
> expected_retval, and which one? Analysing the gcc source code, or the
> X11 source code (by means of grep), in how many cases are those
> functions used, and in how many of those cases are the return values
> relevant for branch prediction? (i.e. how many calls of those
> functions appear in if-statements)
I´ve had basically malloc (with inexpected value of NULL),
feof (1 inexpected), fgetc, fputc and other common memory management/stdio
functions. These are pretty common, but I agree that gain is questionable.
Perhaps most interesting cases would be in stuff like WWW servers etc where
performance matters and I would expect a lot of such calls there...
>
> My feeling is that this could likely add a lot of machinery for little
> gain.
ON gcc part it is quite simple, adding attributes to headers is a lot of
work.
The gain also depends on how well we will be able to use such information..
Currently we have little use of static prediction but this can improve IMO.
Honya
>
> Regards,
> Martin