From mboxrd@z Thu Jan 1 00:00:00 1970 From: Segher Boessenkool Subject: Re: PROPOSAL: Extend inline asm syntax with size spec Date: Sun, 7 Oct 2018 08:22:28 -0500 Message-ID: <20181007132228.GJ29268@gate.crashing.org> References: <20181003213100.189959-1-namit@vmware.com> <20181007091805.GA30687@zn.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Content-Disposition: inline In-Reply-To: <20181007091805.GA30687@zn.tnic> To: Borislav Petkov Cc: gcc@gcc.gnu.org, Richard Biener , Michael Matz , Nadav Amit , Ingo Molnar , linux-kernel@vger.kernel.org, x86@kernel.org, Masahiro Yamada , Sam Ravnborg , Alok Kataria , Christopher Li , Greg Kroah-Hartman , "H. Peter Anvin" , Jan Beulich , Josh Poimboeuf , Juergen Gross , Kate Stewart , Kees Cook , linux-sparse@vger.kernel.org, Peter Zijlstra , Philippe Ombredanne , Thomas Gleixner , virtualization@lists.linux-found List-Id: linux-sparse@vger.kernel.org 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 ("..." : : : : ) This potentially conflicts with the syntax for asm goto. > 3) asm ("...") __attribute__((asm_size())); 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