public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Martin Jambor <mjambor@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920)
Date: Tue, 15 Jan 2013 16:06:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1301151706170.6889@zhemvz.fhfr.qr> (raw)
In-Reply-To: <20130115153856.GX7269@tucnak.redhat.com>

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  <jakub@redhat.com>
> 
> 	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 <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

      reply	other threads:[~2013-01-15 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 15:39 Jakub Jelinek
2013-01-15 16:06 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1301151706170.6889@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=mjambor@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).