From patchwork Mon Oct 31 08:45:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 122761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C0250B6F65 for ; Mon, 31 Oct 2011 19:46:37 +1100 (EST) Received: (qmail 5422 invoked by alias); 31 Oct 2011 08:46:27 -0000 Received: (qmail 5385 invoked by uid 22791); 31 Oct 2011 08:46:24 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Oct 2011 08:46:10 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RKnVQ-00049p-Op from ChungLin_Tang@mentor.com ; Mon, 31 Oct 2011 01:46:08 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 31 Oct 2011 01:46:08 -0700 Received: from [0.0.0.0] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Mon, 31 Oct 2011 01:46:07 -0700 Message-ID: <4EAE6045.7070201@codesourcery.com> Date: Mon, 31 Oct 2011 16:45:57 +0800 From: Chung-Lin Tang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Bernd Schmidt CC: Eric Botcazou , Markus Trippelsdorf , Subject: Re: resent2 [PATCH] Fix ICE in redirect_jump, at jump.c:1497 PR50496 References: <20111014085134.GA1662@x4.trippels.de> <201110171943.36870.ebotcazou@adacore.com> <4E9C6C27.3050301@codesourcery.com> <201110181003.38002.ebotcazou@adacore.com> <4EA5A844.4080607@codesourcery.com> <4EA5A8C2.7060505@codesourcery.com> In-Reply-To: <4EA5A8C2.7060505@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 2011/10/25 02:04 AM, Bernd Schmidt wrote: > On 10/24/11 20:02, Chung-Lin Tang wrote: >> On 2011/10/18 04:03 PM, Eric Botcazou wrote: >>>> thread_prologue_and_epilogue_insns should detect all cases where a >>>> return insn can be created. So any CFG cleanup that runs before it does >>>> not need this functionality. >>> >>> So we're left with CFG cleanups that run after it and could forward edges to an >>> edge from a return insn to the exit block in order to build a new return insn. > > We have no testcases to suggest that this ever happens. Which does mean that, at least through the two call sites that my original patch modified, it may be hard to ever find out later, if patch applied. >> Bernd, why can't we simply remove the assertion? The pre-reload case >> will fail at validation and return 0, matching pre-reload, >> pre-shrink-wrap behavior, while any possible remaining post-reload >> redirection to the exit block can just use 'ret_rtx' as the rare >> fallback > > No, after prologue insertion we have to distinguish between ret_rtx and > simple_return_rtx. I'm suggesting a new patch, as attached. Before reload_completed, we directly return 0 upon nlabel == NULL, which should be identical with old behavior, while asserting fail if after reload (where we assume the simple_return/return distinction is required). This should ensure better that, if a post-prologue case of redirecting to the exit block ever happens we will more easily know (by some future PR :P) Bootstrapped and tested on i686, and cross tested on ARM using QEMU. Eric, is this approach okay? Thanks, Chung-Lin 2011-10-31 Chung-Lin Tang * jump.c (redirect_jump): Assert fail on nlabel == NULL_RTX only after reload. Add comments. Index: jump.c =================================================================== --- jump.c (revision 180421) +++ jump.c (working copy) @@ -1495,8 +1495,19 @@ redirect_jump (rtx jump, rtx nlabel, int delete_un { rtx olabel = JUMP_LABEL (jump); - gcc_assert (nlabel != NULL_RTX); + if (!nlabel) + { + /* For nlabel == NULL_RTX cases, if reload_completed == 0, + return/simple_return are not yet creatable, thus we return 0 + immediately; if reload_completed, we do not accept !nlabel + at all, either a non-null label, or return/simple_return RTX. + In that case assert fail. */ + if (!reload_completed) + return 0; + gcc_unreachable (); + } + if (nlabel == olabel) return 1;