On Sun, Nov 11, 2018 at 02:33:34PM -0700, Martin Sebor wrote: > On 10/30/2018 11:30 AM, Segher Boessenkool wrote: > >The Linux kernel people want a feature that makes GCC pretend some > >inline assembler code is tiny (while it would think it is huge), so > >that such code will be inlined essentially always instead of > >essentially never. > > > >This patch lets you say "asm inline" instead of just "asm", with the > >result that that inline assembler is always counted as minimum cost > >for inlining. It implements this for C and C++. > > Rather than overloading the inline keyword I think it would be > more in keeping both with the design of existing features to > control inlining in GCC and with the way the languages are > evolving to allow the always_inline (and perhaps also noinline) > attribute to apply to asm statements.
We already "overloaded" the volatile and goto keywords here (it's not overloading, the contexts are completely disjoint). always_inline is a function attribute, and you want to make it a statement attribute (which we do not currently support except for empty statements!) as well. > The inline keyword is commonly understood to be just a hint to > the compiler. That is exactly what it is here. It hints the compiler that this asm is cheap, whatever it may look like. > The attributes, on the other hand, are recognized > as binding requests to inline (if possible) or avoid inlining, > respectively. And that is not what this does (that would be hard to do, in fact). > >+You can use @code{asm inline} instead of @code{asm} to have the assembler > >+code counted as mimimum size for inlining purposes; @pxref{Size of an > >asm}. Segher