From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122555 invoked by alias); 3 Mar 2018 16:29:36 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 122540 invoked by uid 89); 3 Mar 2018 16:29:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Conclusion, regstat.c, regstatc, UD:regstat.c X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 03 Mar 2018 16:29:34 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D82483F87; Sat, 3 Mar 2018 16:29:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-22.rdu2.redhat.com [10.10.112.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1DF560BE0; Sat, 3 Mar 2018 16:29:31 +0000 (UTC) Subject: Re: Why does IRA force all pseudos live across a setjmp call to be spilled? To: Peter Bergner Cc: GCC , Vladimir N Makarov , Pat Haugen References: <141cfa78-f202-029a-e530-24e657692bff@vnet.ibm.com> <7e2bab00-e9c8-c05f-9a80-239b9620d979@vnet.ibm.com> From: Jeff Law Message-ID: Date: Sat, 03 Mar 2018 16:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <7e2bab00-e9c8-c05f-9a80-239b9620d979@vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00024.txt.bz2 On 03/02/2018 08:28 PM, Peter Bergner wrote: > On 3/2/18 3:26 PM, Jeff Law wrote: >> On 03/02/2018 12:45 PM, Peter Bergner wrote: >>> ...which forces us to spill everything live across the setjmp by forcing >>> the pseudos to interfere all hardregs. That can't be good for performance. >>> What am I missing? >> >> You might want to hold off a bit. I've got changes for 21161 which can >> help this significantly. Basically the live-across-setjmp set is way >> too conservative -- it includes everything live at the setjmp, but it >> really just needs what's live on the longjump path. >> >> As for why, I believe it's related to trying to make sure everything has >> the right values if we perform a longjmp. > > I can understand why we might save/restore across functions that can throw > exceptions since the program state hasn't been saved at the point of the > call or in the call, but what is special about setjmp()? We don't need > to save/restore the volatile regs since all functions clobber them and > the non-volatile regs are saved/restored by setjmp(), just like any > normal function call. ...and as far as I know, setjmp() doesn't save > or restore the stack contents, just the stack pointer, pc, etc. > So I guess I still don't know why we treat it differently than any > other function call wrt register allocation. Here's the comment from regstat.c: /* We have a problem with any pseudoreg that lives across the setjmp. ANSI says that if a user variable does not change in value between the setjmp and the longjmp, then the longjmp preserves it. This includes longjmp from a place where the pseudo appears dead. (In principle, the value still exists if it is in scope.) If the pseudo goes in a hard reg, some other value may occupy that hard reg where this pseudo is dead, thus clobbering the pseudo. Conclusion: such a pseudo must not go in a hard reg. */