* [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920)
@ 2013-01-15 15:39 Jakub Jelinek
2013-01-15 16:06 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2013-01-15 15:39 UTC (permalink / raw)
To: Richard Biener, Martin Jambor; +Cc: gcc-patches
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?
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920)
2013-01-15 15:39 [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920) Jakub Jelinek
@ 2013-01-15 16:06 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2013-01-15 16:06 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Martin Jambor, gcc-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-15 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 15:39 [PATCH] Ensure matching types in debug stmts created by tree-sra.c (PR tree-optimization/55920) Jakub Jelinek
2013-01-15 16:06 ` Richard Biener
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).