Re: [PATCH 0/3] Clean the new GCC 9 -Wmissing-attributes warnings

From: Miguel Ojeda
Date: Sat Feb 09 2019 - 06:19:46 EST

On Sat, Feb 9, 2019 at 11:44 AM Ard Biesheuvel
<ard.biesheuvel@xxxxxxxxxx> wrote:
> On Sat, 9 Feb 2019 at 01:09, Miguel Ojeda
> <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> >
> > The upcoming GCC 9 release extends the -Wmissing-attributes warnings
> > (enabled by -Wall) to C and aliases: it warns when particular function
> > attributes are missing in the aliases but not in their target, e.g.:
> >
> > void __cold f(void) {}
> Apologies if I missed any discussions on this topic, but I would argue
> that 'cold' is not an attribute that has to be applied to the function
> pointer as well as each of its targets, since it basically decides the
> placement in the binary, and it doesn't affect the nature of the code
> being referenced.

It also affects the optimizer in two different ways AFAIK:

* For the function itself, it gets optimized for size instead of speed.
* For callers, the paths that lead to the calls are treated as unlikely.

So GCC reports it because you would be (likely) missing the
optimizations you expected if you are using the alias instead of the

In our case in patch 3, we do not want the optimization for callers,
which is why we don't mark the extern declaration as __cold (see the
commit message).