re PR tree-optimization/55920 (ICE in expand_debug_locations, at cfgexpand.c:3753)

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.

From-SVN: r195209
This commit is contained in:
Jakub Jelinek 2013-01-15 17:33:24 +01:00 committed by Jakub Jelinek
parent b0fe107eed
commit a7818b54bb
4 changed files with 42 additions and 2 deletions

View File

@ -1,3 +1,10 @@
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.
2013-01-15 Joseph Myers <joseph@codesourcery.com>
Mikael Pettersson <mikpe@it.uu.se>

View File

@ -1,3 +1,8 @@
2013-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/55920
* gcc.c-torture/compile/pr55920.c: New test.
2013-01-15 Richard Biener <rguenther@suse.de>
PR middle-end/55882

View File

@ -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);
}

View File

@ -3108,8 +3108,20 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
if (lacc && lacc->grp_to_be_debug_replaced)
{
gimple ds = gimple_build_debug_bind (get_access_replacement (lacc),
unshare_expr (rhs), *stmt);
tree dlhs = get_access_replacement (lacc);
tree drhs = unshare_expr (rhs);
if (!useless_type_conversion_p (TREE_TYPE (dlhs), TREE_TYPE (drhs)))
{
if (AGGREGATE_TYPE_P (TREE_TYPE (drhs))
&& !contains_vce_or_bfcref_p (drhs))
drhs = build_debug_ref_for_model (loc, drhs, 0, lacc);
if (drhs
&& !useless_type_conversion_p (TREE_TYPE (dlhs),
TREE_TYPE (drhs)))
drhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
TREE_TYPE (dlhs), drhs);
}
gimple ds = gimple_build_debug_bind (dlhs, drhs, *stmt);
gsi_insert_before (gsi, ds, GSI_SAME_STMT);
}