From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by sourceware.org (Postfix) with ESMTPS id 67B653857C46 for ; Tue, 10 Nov 2020 07:52:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 67B653857C46 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=peterz@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=In7qTLSOxzciUyAOC/YtDGAH+bWGejn/ZbOngUYJmwU=; b=uxxlXyauBqaiDU4JkkuQH4peMG yPCg2Lnp4SrglHvjxSgmf3wBGUiab4ZKe2g5og8Quii1YZ2lD7FECk7jnopFm52m2vsHZ19tmtEf6 yOk6SZSxe+r1ZqOMbos82HxXCdlzwIyOnCT873LL9RT1KQk+1BmPRDYLYIHeak+fS7nA501A09Erj f8srikGNb/Mv3/J4Mm6jE0Db/wcIApr+waieGHShIy+YZMtq6oEZBcyM6C8BiLkjQBK75HKSAv2a2 eMLVEY15aPPEU1BBV31x2KGUcIoxXuxDhSetmND9+ko3xbuEGCdx7mGdoQQJPkZFYA6PAp0UGdPN7 5evBm2aw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcOSG-0004hM-Lf; Tue, 10 Nov 2020 07:52:45 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id F1F1C300455; Tue, 10 Nov 2020 08:52:36 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D9E0C2C09A80A; Tue, 10 Nov 2020 08:52:36 +0100 (CET) Date: Tue, 10 Nov 2020 08:52:36 +0100 From: Peter Zijlstra To: Segher Boessenkool Cc: Uros Bizjak , GCC Development , X86 ML , Jakub Jelinek , Andy Lutomirski , linux-toolchains@vger.kernel.org, borntraeger@de.ibm.com, Will Deacon , Linus Torvalds , mpe@ellerman.id.au Subject: Re: typeof and operands in named address spaces Message-ID: <20201110075236.GS2594@hirez.programming.kicks-ass.net> References: <20201109124713.GP2594@hirez.programming.kicks-ass.net> <20201109193851.GI2672@gate.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201109193851.GI2672@gate.crashing.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 07:52:54 -0000 On Mon, Nov 09, 2020 at 01:38:51PM -0600, Segher Boessenkool wrote: > On Mon, Nov 09, 2020 at 01:47:13PM +0100, Peter Zijlstra wrote: > > > > + lots of people and linux-toolchains > > > > On Wed, Nov 04, 2020 at 07:31:42PM +0100, Uros Bizjak wrote: > > > Hello! > > > > > > I was looking at the recent linux patch series [1] where segment > > > qualifiers (named address spaces) were introduced to handle percpu > > > variables. In the patch [2], the author mentions that: > > > > > > --q-- > > > Unfortunately, gcc does not provide a way to remove segment > > > qualifiers, which is needed to use typeof() to create local instances > > > of the per-cpu variable. For this reason, do not use the segment > > > qualifier for per-cpu variables, and do casting using the segment > > > qualifier instead. > > > --/q-- > > > > C in general does not provide means to strip qualifiers. > > Most ways you can try to use the result are undefined behaviour, even. > > > We recently had > > a _lot_ of 'fun' trying to strip volatile from a type, see here: > > > > https://lore.kernel.org/lkml/875zimp0ay.fsf@mpe.ellerman.id.au > > > > which resulted in the current __unqual_scalar_typeof() hack. > > > > If we're going to do compiler extentions here, can we pretty please have > > a sane means of modifying qualifiers in general? > > What do you want to do with it? It may be more feasible to do a > compiler extension for *that*. Like with the parent use-case it's pretty much always declaring temporaries in macros. We don't want the temporaries to be volatile, or as the parent post points out, to have a segment qualifier.