From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28430 invoked by alias); 14 Dec 2018 08:52: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 28418 invoked by uid 89); 14 Dec 2018 08:52:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=10PM, 10pm, sk:PIC_OFF, sk:pic_off X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Dec 2018 08:52:33 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id wBE8qKZ1018179; Fri, 14 Dec 2018 02:52:20 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id wBE8qHVt018174; Fri, 14 Dec 2018 02:52:17 -0600 Date: Fri, 14 Dec 2018 08:52:00 -0000 From: Segher Boessenkool To: Dimitar Dimitrov Cc: Christophe Lyon , Thomas Preudhomme , gcc Patches , Richard Sandiford , "Thomas Preud'homme" Subject: Re: [PATCH] [RFC] PR target/52813 and target/11807 Message-ID: <20181214085217.GM3803@gate.crashing.org> References: <20181209100856.14051-1-dimitar@dinux.eu> <4591520.WeSID5Fo3g@tpdeb> <20181213144837.GD3803@gate.crashing.org> <3948697.eYaff1WIgU@tpdeb> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3948697.eYaff1WIgU@tpdeb> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01024.txt.bz2 On Thu, Dec 13, 2018 at 11:26:40PM +0200, Dimitar Dimitrov wrote: > On Thu, Dec 13, 2018 at 8:48:38 EET Segher Boessenkool wrote: > > On Wed, Dec 12, 2018 at 06:26:10PM +0200, Dimitar Dimitrov wrote: > > > I expect that if I mark a HW register as "clobber", compiler would save > > > its > > > contents before executing the asm statement, and after that it would > > > restore its contents. This is the GCC behaviour for all but the SP and > > > PIC registers. That is why I believe that PR52813 is a valid bug. > > > > It won't do it for *any* fixed registers. But you do not want to error > > or even warn for some fixed registers, for example the "flags" register > > on x86 is *always* written to by asm. > > Yes, you are correct. > > > But you never want to warn for non-fixed registers, and e.g. > > PIC_OFFSET_TABLE_REGNUM isn't always a fixed register (when flag_pic is 0 > > for example). > I could not trace how PIC_OFFSET_TABLE_REGNUM on i386 gets marked as fixed > register. I'll dig more through the source. > > > > I'm not sure how GCC could recover if SP is clobbered. If SP is clobbered > > > in such a way that GCC will not notice (e.g. thread switching), then why > > > should GCC know about it in the first place? > > > > Up until today, GCC has always just ignored it if you claimed to clobber > > the stack pointer. > > My point is that the silent ignoring is confusing to users, as shown by > PR52813. How would you suggest me to proceed: > - Leave patch as-is. > - Revert patch. Update documentation to point that clobber marker for fixed > registers is ignored by GCC. Close PR52813 as invalid. > - Revert patch. Discuss more broadly and specify behaviour of asm clobber for > fixed registers (and SP in particular). You need a few tweaks to what you committed. Or just one perhaps: if flag_pic is not set, you should not check PIC_OFFSET_TABLE_REGNUM, it is meaningless in that case. I'm not sure if you need to check whether the register is fixed or not. But there are many more regs than just the PIC reg and the stack pointer that you would want to similarly warn about, because overwriting those registers is just as fatal: the frame pointer, the program counter, etc. _Most_ fixed registers, but not _all_. So maybe it should be a target hook? OTOH that is a lot of work for such a trivial warning, that isn't very useful anyway (a better warning for any asm is: "Are you sure?" :-) ) So I don't know what is best to do (except that flag_pic part). Sorry. Segher