From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49329 invoked by alias); 15 Nov 2018 16:23:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 49300 invoked by uid 89); 15 Nov 2018 16:23:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=letter, H*F:D*ru X-HELO: smtp.ispras.ru Received: from bran.ispras.ru (HELO smtp.ispras.ru) (83.149.199.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Nov 2018 16:23:32 +0000 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id 9CCBD203C3; Thu, 15 Nov 2018 19:23:28 +0300 (MSK) Date: Thu, 15 Nov 2018 16:23:00 -0000 From: Alexander Monakov To: Michael Matz cc: Segher Boessenkool , Jakub Jelinek , Martin Sebor , Gcc Patch List Subject: Re: [PATCH] diagnose unsupported uses of hardware register variables (PR 88000) In-Reply-To: Message-ID: References: <20181114122250.GZ23873@gate.crashing.org> <20181114122726.GW11625@tucnak> <20181114135305.GB23873@gate.crashing.org> <20181114174723.GD23873@gate.crashing.org> User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2018-11/txt/msg01394.txt.bz2 On Thu, 15 Nov 2018, Michael Matz wrote: > I disagree that there's something to fix. My mental model for local reg > vars has always been that such vars are actually an alias for that > register, not comparable to normal automatic variables (so, much like > global reg vars, except that they don't reserve away the register from > regalloc). I.e. like volatile they can arbitrarily change their value. > I don't know if other peoples mind model is similar, but it certainly is > the model that is implemented in the GIMPLE pipeline (and if memory serves > well of the RTL pipeline as well). Reading the documentation certainly does not make that impression to me. In any case, can you elaborate a bit further please: 1. Regarding the comparison to 'volatile' qualifier. Suppose you have an automatic variable 'int v;' in a correct program. The variable is only used for some arithmetic, never passed to asms, does not have its address taken. Thus, changing its declaration to 'volatile int v;' would not make the program invalid. Now, can declaring it as 'register int v asm("%rbx");' (with a callee-saved register) make the program invalid? My reading of the documentation is that it would provide a regalloc hint and have no ill effects. 2. Are testcases given in PR 87984 valid? Quoting the latest example: int f(void) { int o=0, i; for (i=0; i<3; i++) { register int a asm("eax"); a = 1; asm("add %1, %0" : "+r"(o) : "r"(a)); asm("xor %%eax, %%eax" ::: "eax"); } return o; } This follows both your model and the documentation to the letter, and yet will return 1 rather than 3. I disagree that it is practical to implement your model on GIMPLE. Thanks. Alexander