From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22806 invoked by alias); 15 Jan 2013 16:06:36 -0000 Received: (qmail 22782 invoked by uid 22791); 15 Jan 2013 16:06:34 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,TW_TM X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jan 2013 16:06:26 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 18B6BA51CB; Tue, 15 Jan 2013 17:06:25 +0100 (CET) Date: Tue, 15 Jan 2013 16:06:00 -0000 From: Richard Biener To: Jakub Jelinek Cc: Martin Jambor , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920) In-Reply-To: <20130115153856.GX7269@tucnak.redhat.com> Message-ID: References: <20130115153856.GX7269@tucnak.redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 X-SW-Source: 2013-01/txt/msg00787.txt.bz2 On Tue, 15 Jan 2013, Jakub Jelinek wrote: > Hi! > > This patch fixes ICE on the attached testcase on ARM, where we ended up > creating invalid debug stmt, which had SImode var on the lhs, but BLKmode > MEM_REF on the rhs. Fixed by matching (almost, with the build_ref_for_model > -> build_debug_ref_for_model change) what we do for normal stmt > modifications earlier. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Works for me. Thanks, Richard. > 2013-01-15 Jakub Jelinek > > PR tree-optimization/55920 > * tree-sra.c (sra_modify_assign): If for lacc->grp_to_be_debug_replaced > there is non-useless type conversion needed from debug rhs to lhs, > use build_debug_ref_for_model and/or VIEW_CONVERT_EXPR. > > * gcc.c-torture/compile/pr55920.c: New test. > > --- gcc/tree-sra.c.jj 2013-01-11 09:02:55.000000000 +0100 > +++ gcc/tree-sra.c 2013-01-15 12:52:01.161324202 +0100 > @@ -3108,8 +3108,20 @@ sra_modify_assign (gimple *stmt, gimple_ > > if (lacc && lacc->grp_to_be_debug_replaced) > { > - gimple ds = gimple_build_debug_bind (get_access_replacement (lacc), > - unshare_expr (rhs), *stmt); > + tree debug_lhs = get_access_replacement (lacc); > + tree debug_rhs = unshare_expr (rhs); > + if (!useless_type_conversion_p (TREE_TYPE (debug_lhs), > + TREE_TYPE (debug_rhs))) > + { > + if (AGGREGATE_TYPE_P (TREE_TYPE (debug_rhs)) > + && !contains_vce_or_bfcref_p (debug_rhs)) > + debug_rhs = build_debug_ref_for_model (loc, debug_rhs, 0, lacc); > + if (!useless_type_conversion_p (TREE_TYPE (debug_lhs), > + TREE_TYPE (debug_rhs))) > + debug_rhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR, > + TREE_TYPE (debug_lhs), debug_rhs); > + } > + gimple ds = gimple_build_debug_bind (debug_lhs, debug_rhs, *stmt); > gsi_insert_before (gsi, ds, GSI_SAME_STMT); > } > > --- gcc/testsuite/gcc.c-torture/compile/pr55920.c.jj 2013-01-15 12:58:01.782125163 +0100 > +++ gcc/testsuite/gcc.c-torture/compile/pr55920.c 2013-01-15 12:57:23.000000000 +0100 > @@ -0,0 +1,16 @@ > +/* PR tree-optimization/55920 */ > + > +struct A { unsigned a; } __attribute__((packed)); > +struct B { int b; unsigned char c[16]; }; > +void bar (struct A); > + > +void > +foo (struct B *x) > +{ > + struct A a; > + if (x->b) > + __builtin_memcpy (&a, x->c, sizeof a); > + else > + a.a = 0; > + bar (a); > +} > > Jakub > > -- Richard Biener SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend