aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2009-10-29 13:40:48 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2009-10-29 13:40:48 +0100
commit8a1326b3927310096b72d919ed94fbe7e66a7cdf (patch)
treeee7ef26536e47de8b26bc3f301d655b2c9530064 /gcc/tree-sra.c
parent162e4591aa3f1a7cfb5198bc504dc110bee5a5ca (diff)
downloadgcc-8a1326b3927310096b72d919ed94fbe7e66a7cdf.zip
gcc-8a1326b3927310096b72d919ed94fbe7e66a7cdf.tar.gz
gcc-8a1326b3927310096b72d919ed94fbe7e66a7cdf.tar.bz2
re PR tree-optimization/41775 (IPA-SRA: ice in rewrite_stmt, at tree-into-ssa.c:1302)
2009-10-29 Martin Jambor <mjambor@suse.cz> PR tree-optimization/41775 * tree-sra.c (build_ref_for_offset): Unshare *expr if not NULL. (generate_subtree_copies): Do not unshare agg. (load_assign_lhs_subreplacements): Do not unshare rhs. (sra_modify_assign): Do not unshare exprs. (propagate_subacesses_accross_link): Renamed to propagate_subaccesses_across_link. * testsuite/g++.dg/torture/pr41775.C: New testcase. From-SVN: r153699
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 8624668..a86a441 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1304,7 +1304,8 @@ build_ref_for_offset_1 (tree *res, tree type, HOST_WIDE_INT offset,
/* Construct an expression that would reference a part of aggregate *EXPR of
type TYPE at the given OFFSET of the type EXP_TYPE. If EXPR is NULL, the
function only determines whether it can build such a reference without
- actually doing it.
+ actually doing it, otherwise, the tree it points to is unshared first and
+ then used as a base for furhter sub-references.
FIXME: Eventually this should be replaced with
maybe_fold_offset_to_reference() from tree-ssa-ccp.c but that requires a
@@ -1317,6 +1318,9 @@ build_ref_for_offset (tree *expr, tree type, HOST_WIDE_INT offset,
{
location_t loc = expr ? EXPR_LOCATION (*expr) : UNKNOWN_LOCATION;
+ if (expr)
+ *expr = unshare_expr (*expr);
+
if (allow_ptr && POINTER_TYPE_P (type))
{
type = TREE_TYPE (type);
@@ -1759,7 +1763,7 @@ create_artificial_child_access (struct access *parent, struct access *model,
access but LACC is not, change the type of the latter, if possible. */
static bool
-propagate_subacesses_accross_link (struct access *lacc, struct access *racc)
+propagate_subaccesses_across_link (struct access *lacc, struct access *racc)
{
struct access *rchild;
HOST_WIDE_INT norm_delta = lacc->offset - racc->offset;
@@ -1800,7 +1804,7 @@ propagate_subacesses_accross_link (struct access *lacc, struct access *racc)
rchild->grp_hint = 1;
new_acc->grp_hint |= new_acc->grp_read;
if (rchild->first_child)
- ret |= propagate_subacesses_accross_link (new_acc, rchild);
+ ret |= propagate_subaccesses_across_link (new_acc, rchild);
}
continue;
}
@@ -1818,7 +1822,7 @@ propagate_subacesses_accross_link (struct access *lacc, struct access *racc)
{
ret = true;
if (racc->first_child)
- propagate_subacesses_accross_link (new_acc, rchild);
+ propagate_subaccesses_across_link (new_acc, rchild);
}
}
@@ -1844,7 +1848,7 @@ propagate_all_subaccesses (void)
if (!bitmap_bit_p (candidate_bitmap, DECL_UID (lacc->base)))
continue;
lacc = lacc->group_representative;
- if (propagate_subacesses_accross_link (lacc, racc)
+ if (propagate_subaccesses_across_link (lacc, racc)
&& lacc->first_link)
add_access_to_work_queue (lacc);
}
@@ -1960,7 +1964,7 @@ generate_subtree_copies (struct access *access, tree agg,
{
do
{
- tree expr = unshare_expr (agg);
+ tree expr = agg;
if (chunk_size && access->offset >= start_offset + chunk_size)
return;
@@ -2235,7 +2239,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc,
rhs = unshare_expr (lacc->expr);
else
{
- rhs = unshare_expr (top_racc->base);
+ rhs = top_racc->base;
repl_found = build_ref_for_offset (&rhs,
TREE_TYPE (top_racc->base),
offset, lacc->type, false);
@@ -2372,7 +2376,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
if (AGGREGATE_TYPE_P (TREE_TYPE (lhs))
&& !access_has_children_p (lacc))
{
- tree expr = unshare_expr (lhs);
+ tree expr = lhs;
if (build_ref_for_offset (&expr, TREE_TYPE (lhs), 0,
TREE_TYPE (rhs), false))
{
@@ -2383,7 +2387,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
else if (AGGREGATE_TYPE_P (TREE_TYPE (rhs))
&& !access_has_children_p (racc))
{
- tree expr = unshare_expr (rhs);
+ tree expr = rhs;
if (build_ref_for_offset (&expr, TREE_TYPE (rhs), 0,
TREE_TYPE (lhs), false))
rhs = expr;