Re: linux-next: Tree for May 21 (objtool warnings)
From: Miroslav Benes
Date: Tue May 26 2020 - 12:39:52 EST
On Tue, 26 May 2020, Josh Poimboeuf wrote:
> On Mon, May 25, 2020 at 01:07:27PM +0200, Miroslav Benes wrote:
> > > I'll try to find out which optimization does this, because it is a
> > > slightly different scenario than hiding __noreturn from the callees.
> > > Probably -fno-ipa-pure-const again.
> > And it is indeed -fno-ipa-pure-const again.
> It still seems odd to me that GCC's dead end detection seems to break
> with -fno-ipa-pure-const. Do you know if these issues can be fixed on
> the GCC side?
It is odd. I asked Martin and Martin about that yesterday (CCed). It could
be possible to enable just noreturn propagation for -flive-patching if I
understood correctly. The attribute would need to be preserved in a
patched function then, but that should be manageable.
Marking functions as __noreturn is one thing (I think it is useful on its
own as mentioned in the older thread about -flive-patching), but
__always_inline solution in this case is really arbitrary. I don't like
this neverending "battle" with compilers much, so it would be nice to have
some kind of generic solution (and I currently have no idea about that).
Of course, declaring -flive-patching a failed experiment is an option if
there is not a better way to deal with a dead end detection either in GCC
or in objtool. I would not like it, but you're right that if there are
more and more problems like this appearing, we'll have to deal with
maintainers all over the place and ask them to maintain odd fixes just for
the sake of -flive-patching. I don't know what the current numbers are
though. We'd have to approach the problem of GCC optimizations from a
different angle. Petr CCed (we talked about it yesterday as well).
But first, let's try to find a way with -flive-patching.
Reduced test case follows (courtesty of Martin Liska):
$ cat open.i
asm(".byte 15, 0x0b");
void chmod_common_delegated_inode(int arg)
$ gcc open.i -c -Os -fno-omit-frame-pointer -fno-ipa-pure-const && ./tools/objtool/objtool check open.o
open.o: warning: objtool: chmod_common_delegated_inode()+0x18: unreachable instruction
$ gcc open.i -c -Os -fno-omit-frame-pointer && ./tools/objtool/objtool check open.o
So it is a similar problem. There is no noreturn attribute anywhere
(nothing to propagate from a caller to a callee). Here, the information
about an unreachable code is not propagated to the caller
Martins, would it be possible to extend -flive-patching to deal with this?