From patchwork Tue Jun 30 03:07:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 489473 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 590B5140780 for ; Tue, 30 Jun 2015 13:08:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mkxdAaDl; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=jwyNo3pEsOpHoZS AhLfERMhWEgbuTjddktWY3twXApY+eqdwyUfixLZ1yMXmKNO7u0AOIJpRgwQYf2Q 8IUmZ+UUK0PRzr7FX7fW7FNTRqThT2dvrvIbyXvXSVPeZLKJL77SsrkKmmF5QrHP Q0N+Qm3W1xIUS4X5FDab3AlHiCfQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=tALE28FMjt6HTsHvDoUU8 //igxU=; b=mkxdAaDl8WP0P/ppSW3HCPqIHh5e8RSm3IOndyvDgFEf+xj976b0p ghxqy1FK/rXt6lORGn/12XGwVOmYkP7xPkciFmVq7SOE7UI5ldZFRL5SQtCVkUt3 PmnJ9TpUddthiDjsE7QlNMr3gdlgZZau7nzNI1CSVc6pmY3n1gmRzI= Received: (qmail 58113 invoked by alias); 30 Jun 2015 03:08:25 -0000 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 Received: (qmail 58098 invoked by uid 89); 30 Jun 2015 03:08:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f176.google.com Received: from mail-ie0-f176.google.com (HELO mail-ie0-f176.google.com) (209.85.223.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 30 Jun 2015 03:08:14 +0000 Received: by iecuq6 with SMTP id uq6so3664058iec.2 for ; Mon, 29 Jun 2015 20:08:12 -0700 (PDT) X-Received: by 10.50.142.9 with SMTP id rs9mr20088109igb.17.1435633692692; Mon, 29 Jun 2015 20:08:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.188.133 with HTTP; Mon, 29 Jun 2015 20:07:53 -0700 (PDT) In-Reply-To: <5590624E.8090409@codesourcery.com> References: <5581AA41.7010201@codesourcery.com> <1919634.FPIRa5rfyH@polaris> <558A0130.9010202@codesourcery.com> <558B7998.80201@redhat.com> <5590624E.8090409@codesourcery.com> From: Kito Cheng Date: Tue, 30 Jun 2015 11:07:53 +0800 Message-ID: Subject: Re: [patch] fix regrename pass to ensure renamings produce valid insns To: Sandra Loosemore Cc: Jeff Law , Eric Botcazou , "gcc-patches@gcc.gnu.org" , Chung-Lin Tang , Marcus Shawcroft , Richard Earnshaw , "Schmidt, Bernd - Code Sourcery" X-IsSubscribed: yes Hi all: This patch seem will broken when disable assert checking for c6x.... On Mon, Jun 29, 2015 at 5:08 AM, Sandra Loosemore wrote: > On 06/24/2015 09:46 PM, Jeff Law wrote: >> >> On 06/23/2015 07:00 PM, Sandra Loosemore wrote: >>> >>> On 06/18/2015 11:32 AM, Eric Botcazou wrote: >>>>> >>>>> The attached patch teaches regrename to validate insns affected by each >>>>> register renaming before making the change. I can see at least two >>>>> other ways to handle this -- earlier, by rejecting renamings that >>>>> result >>>>> in invalid instructions when it's searching for the best renaming; or >>>>> later, by validating the entire set of renamings as a group instead of >>>>> incrementally for each one -- but doing it all in regname_do_replace >>>>> seems least disruptive and risky in terms of the existing code. >>>> >>>> >>>> OK, but the patch looks incomplete, rename_chains should be adjusted >>>> as well, >>>> i.e. regrename_do_replace should now return a boolean. >>> >>> >>> Like this? I tested this on nios2 and x86_64-linux-gnu, as before, plus >>> built for aarch64-linux-gnu and ran the gcc testsuite. >>> >>> The c6x back end also calls regrename_do_replace. I am not set up to >>> build or test on that target, and Bernd told me off-list that it would >>> never fail on that target anyway so I have left that code alone. >>> >>> -Sandra >>> >>> regrename-2.log >>> >>> >>> 2015-06-23 Chung-Lin Tang >>> Sandra Loosemore >>> >>> gcc/ >>> * regrename.h (regrename_do_replace): Change to return bool. >>> * regrename.c (rename_chains): Check return value of >>> regname_do_replace. >>> (regrename_do_replace): Re-validate the modified insns and >>> return bool status. >>> * config/aarch64/cortex-a57-fma-steering.c (rename_single_chain): >>> Update to match rename_chains changes. >> >> As Eric mentioned, please put an assert to verify that the call from the >> c6x backend never fails. >> >> The regrename and ARM bits are fine. >> >> Do you have a testcase that you can add to the suite? If so it'd be >> appreciated if you could include that too. >> >> Approved with the c6x assert if a testcase isn't available or >> exceedingly difficult to produce. > > > Thanks. I've committed the attached version. > > Re the testcase, this fixed 16 FAILs on existing tests in the gcc testsuite > with the forthcoming nios2 load/store multiple instruction support, all > assembler errors due to the bad instructions being generated. There's > nothing I can do on nios2 for a testcase until I get those patches committed > (I'm still trying to re-test and tidy them up for submission), plus I think > the failures are rather fragile -- depending on the register allocator > choosing an initial register numbering that allows peephole optimizers to > trigger, etc. But, I will revisit this later and see what I can do. > > -Sandra > Index: gcc/config/c6x/c6x.c =================================================================== --- gcc/config/c6x/c6x.c (revision 225104) +++ gcc/config/c6x/c6x.c (working copy) @@ -3516,7 +3516,7 @@ try_rename_operands (rtx_insn *head, rtx best_reg = find_rename_reg (this_head, super_class, &unavailable, old_reg, true); - regrename_do_replace (this_head, best_reg); + gcc_assert (regrename_do_replace (this_head, best_reg)); count_unit_reqs (new_reqs, head, PREV_INSN (tail)); merge_unit_reqs (new_reqs); @@ -3529,7 +3529,7 @@ try_rename_operands (rtx_insn *head, rtx unit_req_imbalance (reqs), unit_req_imbalance (new_reqs)); } if (unit_req_imbalance (new_reqs) > unit_req_imbalance (reqs)) - regrename_do_replace (this_head, old_reg); + gcc_assert (regrename_do_replace (this_head, old_reg)); else memcpy (reqs, new_reqs, sizeof (unit_req_table));