This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PROPOSAL: Extend inline asm syntax with size spec
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Borislav Petkov <bp at alien8 dot de>
- Cc: gcc at gcc dot gnu dot org, Richard Biener <rguenther at suse dot de>, Michael Matz <matz at suse dot de>, Nadav Amit <namit at vmware dot com>, Ingo Molnar <mingo at redhat dot com>, linux-kernel at vger dot kernel dot org, x86 at kernel dot org, Masahiro Yamada <yamada dot masahiro at socionext dot com>, Sam Ravnborg <sam at ravnborg dot org>, Alok Kataria <akataria at vmware dot com>, Christopher Li <sparse at chrisli dot org>, Greg Kroah-Hartman <gregkh at linuxfoundation dot org>, "H. Peter Anvin" <hpa at zytor dot com>, Jan Beulich <JBeulich at suse dot com>, Josh Poimboeuf <jpoimboe at redhat dot com>, Juergen Gross <jgross at suse dot com>, Kate Stewart <kstewart at linuxfoundation dot org>, Kees Cook <keescook at chromium dot org>, linux-sparse at vger dot kernel dot org, Peter Zijlstra <peterz at infradead dot org>, Philippe Ombredanne <pombredanne at nexb dot com>, Thomas Gleixner <tglx at linutronix dot de>, virtualization at lists dot linux-foundation dot org, Linus Torvalds <torvalds at linux-foundation dot org>, Chris Zankel <chris at zankel dot net>, Max Filippov <jcmvbkbc at gmail dot com>, linux-xtensa at linux-xtensa dot org
- Date: Sun, 7 Oct 2018 08:22:28 -0500
- Subject: Re: PROPOSAL: Extend inline asm syntax with size spec
- References: <20181003213100.189959-1-namit@vmware.com> <20181007091805.GA30687@zn.tnic>
On Sun, Oct 07, 2018 at 11:18:06AM +0200, Borislav Petkov wrote:
> this is an attempt to see whether gcc's inline asm heuristic when
> estimating inline asm statements' cost for better inlining can be
> improved.
GCC already estimates the *size* of inline asm, and this is required
*for correctness*. So any workaround that works against this will only
end in tears.
Taking size as an estimate of cost is not very good. But in your
motivating example you actually *do* care mostly about size, namely, for
the inlining decisions.
So I guess the real issue is that the inline asm size estimate for x86
isn't very good (since it has to be pessimistic, and x86 insns can be
huge)?
> Now, Richard suggested doing something like:
>
> 1) inline asm ("...")
What would the semantics of this be?
> 2) asm ("..." : : : : <size-expr>)
This potentially conflicts with the syntax for asm goto.
> 3) asm ("...") __attribute__((asm_size(<size-expr>)));
Eww.
> with which user can tell gcc what the size of that inline asm statement
> is and thus allow for more precise cost estimation and in the end better
> inlining.
More precise *size* estimates, yes. And if the user lies he should not
be surprised to get assembler errors, etc.
> And FWIW 3) looks pretty straight-forward to me because attributes are
> pretty common anyways.
I don't like 2) either. But 1) looks interesting, depends what its
semantics would be? "Don't count this insn's size for inlining decisions",
maybe?
Another option is to just force inlining for those few functions where
GCC currently makes an inlining decision you don't like. Or are there
more than a few?
Segher