Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E4DDC2D0E4 for ; Tue, 17 Nov 2020 22:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC5C22151B for ; Tue, 17 Nov 2020 22:16:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="VOx1tAVC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbgKQWPv (ORCPT ); Tue, 17 Nov 2020 17:15:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:35602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbgKQWPv (ORCPT ); Tue, 17 Nov 2020 17:15:51 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F19BA2151B; Tue, 17 Nov 2020 22:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605651350; bh=gH8JnJ/oK/HYuLW/O79H47kOTs5ClJ/0LArg096gH+4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VOx1tAVCiTRixzdFaszgoLmltckt16IZhYVvAqTlJonPXjBlFq65zYwncJK6JVEde WdQva36Ib2xy6jBTvretfbQ/KMNI2nWjrcKreZ+5nO5ECDhHooVB4um0Swqnw6Cok+ O9nlCb0qmxPvgA6OHNmuxm7psRwmJf1EAHp9P+xI= Date: Tue, 17 Nov 2020 22:15:45 +0000 From: Will Deacon To: Linus Torvalds Cc: Jakub Jelinek , Peter Zijlstra , "gcc@gcc.gnu.org" , linux-toolchains@vger.kernel.org, "Uecker, Martin" , "amonakov@ispras.ru" , "ubizjak@gmail.com" , "luto@kernel.org" Subject: Re: Re: typeof and operands in named address spaces Message-ID: <20201117221545.GA524@willie-the-truck> References: <1605437478.5370.9.camel@med.uni-goettingen.de> <20201116111056.GA3121378@hirez.programming.kicks-ass.net> <20201117192530.GA3788@tucnak> <20201117211053.GA32727@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117211053.GA32727@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Tue, Nov 17, 2020 at 09:10:53PM +0000, Will Deacon wrote: > On Tue, Nov 17, 2020 at 11:31:57AM -0800, Linus Torvalds wrote: > > On Tue, Nov 17, 2020 at 11:25 AM Jakub Jelinek wrote: > > > > > > It would need to be typeof( (typeof(type)) (type) ) to not be that > > > constrained on what kind of expressions it accepts as arguments. > > > > Yup. > > > > > Anyway, it won't work with array types at least, > > > int a[10]; > > > typeof ((typeof (a)) (a)) b; > > > is an error (in both gcc and clang), while typeof (a) b; will work > > > (but not drop the qualifiers). Don't know if the kernel cares or not. > > > > Well, the kernel already doesn't allow that, because our existing > > horror only handles simple integer scalar types. > > > > So that macro is a clear improvement - if it actually works (local > > testing says it does, but who knows about random compiler versions > > etc) > > I'll give it a go now, although if it works I honestly won't know whether > to laugh or cry. GCC 9 and Clang 11 both seem to generate decent code for aarch64 defconfig with: #define __unqual_scalar_typeof(x) typeof( (typeof(x)) (x)) replacing the current monstrosity. allnoconfig and allmodconfig build fine too. However, GCC 4.9.0 goes mad and starts spilling to the stack when dealing with a pointer to volatile, as though we were just using typeof(). I tried GCC 5.4.0 and that looks ok, so I think if anybody cares about the potential performance regression with 4.9 then perhaps they should consider upgrading their toolchain. In other words, let's do it. Will