Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3316230imm; Mon, 8 Oct 2018 01:45:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV62vbkxHdl1RCsVsVMgE1FGl3drpA7W6sOXdQqLACjuvg/oY6Bcaxgl5UfGNv9K41XKxS0Uf X-Received: by 2002:a63:f922:: with SMTP id h34-v6mr20212669pgi.154.1538988320373; Mon, 08 Oct 2018 01:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538988320; cv=none; d=google.com; s=arc-20160816; b=yu2FtcGO+Deo7tUvgucgv+6F44sF96tcSVAGqoVDhv4K4KJWtJX6aIr0igUUckPihR RMD4Yy/L6cBCK5bolruFpKcUbj8/2qHKe6k/YRBG4Id0MCHdv8CNNsZlwOROp4huaUwe 4O/lDiKcDKYd1SDW6sdJEshd9HA0bO0wlg+XOEDpscU+bqUdLY6SO09i/T5VxGPVrcXy O86Lj56zVI9Eqd3klPd2gmulb1UvKJ9X7OPo6bZky3N012Mwj7pTlOupf5eXKzGJa7IP rsCl93jQcCSg2X3MOYeGsJqQz8MRoL/3yHZJGptdtBtcqZ7OuaIX8MKTVBCKta0B1Q1o ctmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+ZUWz5MpL0ZfWVh+LZWd2YZzTuTBrS9Mmr7jYJGlNok=; b=b2zZQZF35PrXE2PHffpNMnKBwWwk7F6+BpP+/LVgmUN7f+014JaZ2OKwIMosdUdhcv 0WJlxzqKdbzxGB5xvRoLdB055e9D5kx1xYUmde7iac0qmWG5BRO2HEH+7T0RNsS+ijVL G3KU0qi5Bs7rl7WmaJb/CU9okp7vPAv6xiYuwI3dmYncKwtBDFFE0BEuxyGPaq14sAj3 aw01o66HF7siSRu8u4ERRyj2Mk7Sv3vS6IM9dcuVt6BGH7Ya4LElm0HwES3CRVoIXEFZ +QML1bYhqH6WC0uDIOFTeyUmpsx6SIwenikQ6EWQKb7jMXNwPWhITIrHwh9FLUMlypRH 4BkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14-v6si17006945plo.208.2018.10.08.01.45.04; Mon, 08 Oct 2018 01:45:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726656AbeJHPzf (ORCPT + 99 others); Mon, 8 Oct 2018 11:55:35 -0400 Received: from gate.crashing.org ([63.228.1.57]:36642 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbeJHPzf (ORCPT ); Mon, 8 Oct 2018 11:55:35 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w988J2nD017464; Mon, 8 Oct 2018 03:19:02 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id w988IvN3017410; Mon, 8 Oct 2018 03:18:57 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 8 Oct 2018 03:18:57 -0500 From: Segher Boessenkool To: Ingo Molnar Cc: Michael Matz , Borislav Petkov , gcc@gcc.gnu.org, Richard Biener , 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-foundation.org, Linus Torvalds , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Subject: Re: PROPOSAL: Extend inline asm syntax with size spec Message-ID: <20181008081856.GO29268@gate.crashing.org> References: <20181003213100.189959-1-namit@vmware.com> <20181007091805.GA30687@zn.tnic> <20181007132228.GJ29268@gate.crashing.org> <20181008061323.GB66819@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181008061323.GB66819@gmail.com> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 08, 2018 at 08:13:23AM +0200, Ingo Molnar wrote: > * Michael Matz wrote: > > (without an built-in assembler which hopefully noone proposes). > There are disadvantages (the main one is having to implement it), but a built-in assembler has > numerous advantages as well: > > - Better optimizations: for example -Os could more accurately estimate true instruction size. GCC already knows the exact instruction size in almost all cases, for most backends. It is an advantage to not *have to* keep track of exact insn size in all cases. > - Better inlining: as the examples in this thread are showing. That's a red herring, the actual issue is inlining makes some spectacularly wrong decisions for code involving asm currently. That would not be solved by outputting binary code instead of assembler code. All those decisions are done long before code is output. > - Better padding/alignment: right now GCC has no notion about the precise cache layout of the > assembly code it generates and the code alignment options it has are crude. This isn't true. Maybe some targets do not care. And of course GCC only knows this as far as it knows the alignments of the sections it outputs into; for example, ASLR is a nice performance killer at times. And if your linker scripts align sections to less than a cache line things do not look rosy either, etc. > It got away with > this so far because the x86 rule of thumb is that dense code is usually the right choice. > - Better compiler performance: it would be faster as well to immediately emit assembly > instructions, just like GCC's preprocessor library use speeds up compilation *significantly* > instead of creating a separate preprocessor task. So how much faster do you think it would be? Do you have actual numbers? And no, -O0 does not count. > - Better future integration of assembly blocks: GCC could begin to actually understand the > assembly statements in inline asm and allow more user-friendly extensions to its > historically complex and difficult to master inline asm syntax. If you want to add a different kind of inline assembler, you can already. There is no need for outputting binary code for that. > I mean, it's a fact that the GNU project has *already* defined their own assembly syntax which > departs from decades old platform assembly syntax GCC's asm syntax is over three decades old itself. When it was defined all other C inline assembler syntaxes were much younger than that. I don't see what your argument is here. > - and how the assembler is called by the > compiler is basically an implementation detail, not a conceptual choice. But the *format* of the interface representation, in this case textual assembler code, is quite fundamental. > The random > multi-process unidirectional assembler choice of the past should not be treated as orthodoxy. Then I have good news for you: no assembler works that way these days, and that has been true for decades. Segher