From patchwork Sat Sep 7 13:01:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 273381 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 219C02C011F for ; Sat, 7 Sep 2013 23:01:41 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=cGVTNKhuKlkyLCBl n7JsujLF76qcg5PcY82MLRwT+P5v9ni4RHSR/peXDeUmJdG4h7jLhtlWjR4hORUt 5YBHxeoNafGwDKfLHFkcv+SPROZm3pQdlYOv6ZIAS9Va5JmxXpNa48fAPZJD+sZo noez0GEq3X5hHG7SsjaeooYTeNo= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=rrX/tkddfWLNHE40XG3b2/ 9XwtQ=; b=M5GTfGEYu+ijFPIEsBgtWDWc6ij9zyTwJsH0ZJVwhauaJhjGgtSIov 6wbRRnkoeWqCItHzKb8a5wlz7ck2UEeuheZeWUBo8NWhbniv82uGxOajbxHlzFrC e0/wd+42X9bRenor3GsXA1g9F1fk6sUCVfcbNFerTaOMsJaFfWBoI= Received: (qmail 16938 invoked by alias); 7 Sep 2013 13:01:34 -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 16922 invoked by uid 89); 7 Sep 2013 13:01:32 -0000 Received: from mail-wi0-f172.google.com (HELO mail-wi0-f172.google.com) (209.85.212.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 07 Sep 2013 13:01:32 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, FREEMAIL_FROM autolearn=ham version=3.3.2 X-HELO: mail-wi0-f172.google.com Received: by mail-wi0-f172.google.com with SMTP id c10so1877467wiw.5 for ; Sat, 07 Sep 2013 06:01:28 -0700 (PDT) X-Received: by 10.180.89.101 with SMTP id bn5mr2068564wib.39.1378558888083; Sat, 07 Sep 2013 06:01:28 -0700 (PDT) Received: from localhost ([2.26.203.233]) by mx.google.com with ESMTPSA id li9sm3544051wic.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 07 Sep 2013 06:01:27 -0700 (PDT) From: Richard Sandiford To: Jakub Jelinek Mail-Followup-To: Jakub Jelinek , Steven Bosscher , GCC Patches , Vladimir Makarov , rdsandiford@googlemail.com Cc: Steven Bosscher , GCC Patches , Vladimir Makarov Subject: Re: RFA: Fix debug-insn sensitivity in RA References: <87a9jpj8mq.fsf@talisman.default> <87sixgj21h.fsf@talisman.default> <20130907114240.GW23437@tucnak.redhat.com> Date: Sat, 07 Sep 2013 14:01:26 +0100 In-Reply-To: <20130907114240.GW23437@tucnak.redhat.com> (Jakub Jelinek's message of "Sat, 7 Sep 2013 13:42:40 +0200") Message-ID: <87fvtgiy55.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Jakub Jelinek writes: > On Sat, Sep 07, 2013 at 12:37:14PM +0100, Richard Sandiford wrote: >> Steven Bosscher writes: >> > Can you please add a test case? >> >> What kind of test would you suggest? Do we have a harness for testing >> that -O2 and -O2 -g .text output is identical? > > No, but we have -fcompare-debug, which is even stronger than that (compares > final RTL, so can catch even differences that aren't visible in the .s file, > but still are relevant). And, the default way of bootstrapping also > compares .text etc. after stripping, between stage2 (built without debug) > and stage3 (with debug). Here's the patch again with an -fcompare-debug test. I spent a while trying to whittle it down, but beyond this it gets very sensitive. OK to install? Richard gcc/ * ira.c (update_equiv_regs): Only call set_paradoxical_subreg for non-debug insns. * lra.c (new_insn_reg): Take the containing insn as a parameter. Only modify lra_reg_info[].biggest_mode if it's non-debug insn. (collect_non_operand_hard_regs, add_regs_to_insn_regno_info): Update accordingly. gcc/testsuite/ * g++.dg/debug/ra1.C: New test. Index: gcc/ira.c =================================================================== --- gcc/ira.c 2013-09-07 13:59:23.049113927 +0100 +++ gcc/ira.c 2013-09-07 13:59:26.362142367 +0100 @@ -2944,11 +2944,8 @@ update_equiv_regs (void) prevent access beyond allocated memory for paradoxical memory subreg. */ FOR_EACH_BB (bb) FOR_BB_INSNS (bb, insn) - { - if (! INSN_P (insn)) - continue; - for_each_rtx (&insn, set_paradoxical_subreg, (void *)pdx_subregs); - } + if (NONDEBUG_INSN_P (insn)) + for_each_rtx (&insn, set_paradoxical_subreg, (void *) pdx_subregs); /* Scan the insns and find which registers have equivalences. Do this in a separate scan of the insns because (due to -fcse-follow-jumps) Index: gcc/lra.c =================================================================== --- gcc/lra.c 2013-09-07 13:59:23.049113927 +0100 +++ gcc/lra.c 2013-09-07 13:59:26.363142375 +0100 @@ -480,13 +480,13 @@ init_insn_regs (void) = create_alloc_pool ("insn regs", sizeof (struct lra_insn_reg), 100); } -/* Create LRA insn related info about referenced REGNO with TYPE - (in/out/inout), biggest reference mode MODE, flag that it is +/* Create LRA insn related info about a reference to REGNO in INSN with + TYPE (in/out/inout), biggest reference mode MODE, flag that it is reference through subreg (SUBREG_P), flag that is early clobbered in the insn (EARLY_CLOBBER), and reference to the next insn reg info (NEXT). */ static struct lra_insn_reg * -new_insn_reg (int regno, enum op_type type, enum machine_mode mode, +new_insn_reg (rtx insn, int regno, enum op_type type, enum machine_mode mode, bool subreg_p, bool early_clobber, struct lra_insn_reg *next) { struct lra_insn_reg *ir; @@ -494,7 +494,8 @@ new_insn_reg (int regno, enum op_type ty ir = (struct lra_insn_reg *) pool_alloc (insn_reg_pool); ir->type = type; ir->biggest_mode = mode; - if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (lra_reg_info[regno].biggest_mode)) + if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (lra_reg_info[regno].biggest_mode) + && NONDEBUG_INSN_P (insn)) lra_reg_info[regno].biggest_mode = mode; ir->subreg_p = subreg_p; ir->early_clobber = early_clobber; @@ -976,7 +977,7 @@ collect_non_operand_hard_regs (rtx *x, l && ! (FIRST_STACK_REG <= regno && regno <= LAST_STACK_REG)); #endif - list = new_insn_reg (regno, type, mode, subreg_p, + list = new_insn_reg (data->insn, regno, type, mode, subreg_p, early_clobber, list); } } @@ -1575,7 +1576,7 @@ add_regs_to_insn_regno_info (lra_insn_re expand_reg_info (); if (bitmap_set_bit (&lra_reg_info[regno].insn_bitmap, uid)) { - data->regs = new_insn_reg (regno, type, mode, subreg_p, + data->regs = new_insn_reg (data->insn, regno, type, mode, subreg_p, early_clobber, data->regs); return; } @@ -1587,8 +1588,9 @@ add_regs_to_insn_regno_info (lra_insn_re if (curr->subreg_p != subreg_p || curr->biggest_mode != mode) /* The info can not be integrated into the found structure. */ - data->regs = new_insn_reg (regno, type, mode, subreg_p, - early_clobber, data->regs); + data->regs = new_insn_reg (data->insn, regno, type, mode, + subreg_p, early_clobber, + data->regs); else { if (curr->type != type) Index: gcc/testsuite/g++.dg/debug/ra1.C =================================================================== --- /dev/null 2013-09-07 09:29:02.438764162 +0100 +++ gcc/testsuite/g++.dg/debug/ra1.C 2013-09-07 14:00:09.653513821 +0100 @@ -0,0 +1,77 @@ +/* { dg-options "-fcompare-debug" } */ + +enum signop { SIGNED, UNSIGNED }; +enum tree_code { FOO, BAR }; +enum tree_code_class { tcc_type, tcc_other }; +extern enum tree_code_class tree_code_type[]; + +struct tree_base { + enum tree_code code : 16; + unsigned unsigned_flag : 1; +}; + +struct tree_def { + tree_base base; + struct { + int precision; + } type_common; +}; + +typedef tree_def *tree; + +struct storage_ref +{ + storage_ref (const long *, unsigned int, unsigned int); + + const long *val; + unsigned int len; + unsigned int precision; +}; + +inline storage_ref::storage_ref (const long *val_in, + unsigned int len_in, + unsigned int precision_in) + : val (val_in), len (len_in), precision (precision_in) +{ +} + +struct hwi_with_prec +{ + long val; + unsigned int precision; + signop sgn; +}; + +inline storage_ref +decompose (long *scratch, unsigned int precision, + const hwi_with_prec &x) +{ + scratch[0] = x.val; + if (x.sgn == SIGNED || x.val >= 0 || precision <= sizeof (long) * 8) + return storage_ref (scratch, 1, precision); + scratch[1] = 0; + return storage_ref (scratch, 2, precision); +} + +extern void tree_class_check_failed (int) __attribute__ ((__noreturn__)); + +inline tree +tree_class_check (tree t, const enum tree_code_class cls, int x) +{ + if (tree_code_type[t->base.code] != cls) + tree_class_check_failed (x); + return t; +} + +tree wide_int_to_tree (tree, const storage_ref &); + +tree +build_int_cstu (tree type, unsigned long val) +{ + hwi_with_prec x; + x.val = val; + x.precision = tree_class_check (type, tcc_type, 1)->type_common.precision; + x.sgn = (signop) tree_class_check (type, tcc_type, 2)->base.unsigned_flag; + long scratch[2]; + return wide_int_to_tree (type, decompose (scratch, x.precision, x)); +}