From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93327 invoked by alias); 6 Mar 2018 16:31:30 -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 93258 invoked by uid 89); 6 Mar 2018 16:31:21 -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,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=crucial, paint, pictures, air X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 16:31:20 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DA963AF3F; Tue, 6 Mar 2018 16:31:17 +0000 (UTC) Date: Tue, 06 Mar 2018 16:31:00 -0000 From: Michael Matz To: Richard Biener cc: Jeff Law , gcc-patches Subject: Re: [RFA][PATCH][PR middle-end/61118] Improve tree CFG accuracy for setjmp/longjmp In-Reply-To: Message-ID: References: <93b4b8a7-c6fe-65c0-0609-62ebee669967@redhat.com> <80db4b7a-9b15-4c09-222e-646d68fdf6c0@redhat.com> <0869f1e3-78f3-7601-225e-e97ad68b5609@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00271.txt.bz2 Hi, On Tue, 6 Mar 2018, Richard Biener wrote: > > bb1 > > ret = setjmp(buf) > > | \ bb-recv > > | ----------------\ > > | ret = setjmp_receiver > > | / > > normal /---------------/ > > path / > > | / > > bb-succ > > > > None of these edges would be abnormal. bb-recv would be the target for > > edges from all calls that might call longjmp(buf). Those edges might need > > to be abnormal. As the above CFG reflects all runtime effects precisely, > > but not which instructions are used to achieve them the expansion to RTL > > will be special. > > Why do you still have the edge from setjmp to the setjmp receiver? Ah, yes, that needs explanation. Without that edge the receiver hangs in the air, so to speak. But all effects that happened before the setjmp invocation also have happened before the second return, so the setjmp_receiver needs to be dominated by the setjmp call, and that requires and CFG edge. A different way of thinking about this is that both "calls" need VDEF/VUSE, and the VUSE of setjmp_receiver needs to be the VDEF of the setjmp, so again that edge needs to be there for ordering reasons. At least that's the obvious way of ordering. Thinking harder might make the edge unnecessary after all: all paths leading to longjmps need to go through a setjmp, so the call->receiver edges are already ordered behind setjmp calls (though not necessarily dominated by them), so the receiver is, and so we might be fine. I'd have to paint some pictures on our board to see how this behaves with multiple reaching setjmps. > In your scheme ret is set twice on the longjmp return path, no? No, it's set once on the first-return path, and once on the second-return path (from longjmp to setjmp_receiver, which sets ret, the set of the setjmp call isn't done on the second-return path). Which is indeed what happens in reality, the return register is set once on first-return and once on second-return. > That is, you have the same issue left as we have with EH returns from a > stmt with a LHS. I don't see that, which problem? > We currently have two outgoing edges from setjmp, one which feeds back > to right before the setjmp call via the abnormal dispatcher (so it looks > like a loop). Jeffs change will make it two outgoing edges to the same > single successor, one dispatched through the abnormal dispatcher (that > also nicely gets around the limitation of only having a single edge > between two blocks...) The crucial thing that needs to happen is that all paths from longjmp to the normal successor of the setjmp call contain an assignment to LHS. The edges out of setjmp aren't the important thing for this, the destination of edges from the dispatcher are (because that's the one targeted by the longjmp calls). And IIUC Jeffs patch makes those edges target something after the LHS-set, and this can't be right. Make the dispatcher set an LHS (and hence have one per setjmp, not one per function) and you're effectively ending up with my proposal above. Ciao, ichael.