* [PATCH] Do not leak SSA names in PRE
@ 2012-12-13 9:27 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2012-12-13 9:27 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 250 bytes --]
When PRE creates representatives for expressions during PHI translation it never
releases the SSA names again. The following patch arranges for SCCVN to release
them.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
[-- Attachment #2: p3 --]
[-- Type: application/octet-stream, Size: 3078 bytes --]
2012-12-13 Richard Biener <rguenther@suse.de>
* tree-ssa-pre.c (get_representative_for): Adjust dumping.
Mark created SSA names for release.
(eliminate_bb): Insert only when expr is not NULL.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c (revision 194444)
--- gcc/tree-ssa-pre.c (working copy)
*************** get_representative_for (const pre_expr e
*** 1395,1425 ****
pre_expr rep = expression_for_id (i);
if (rep->kind == NAME)
return PRE_EXPR_NAME (rep);
}
}
break;
}
/* If we reached here we couldn't find an SSA_NAME. This can
happen when we've discovered a value that has never appeared in
! the program as set to an SSA_NAME, most likely as the result of
! phi translation. */
! if (dump_file)
! {
! fprintf (dump_file,
! "Could not find SSA_NAME representative for expression:");
! print_pre_expr (dump_file, e);
! fprintf (dump_file, "\n");
! }
!
! /* Build and insert the assignment of the end result to the temporary
! that we will return. */
name = make_temp_ssa_name (get_expr_type (e), gimple_build_nop (), "pretmp");
VN_INFO_GET (name)->value_id = value_id;
! VN_INFO (name)->valnum = sccvn_valnum_from_value_id (value_id);
! if (VN_INFO (name)->valnum == NULL_TREE)
! VN_INFO (name)->valnum = name;
add_to_value (value_id, get_or_alloc_expr_for_name (name));
! if (dump_file)
{
fprintf (dump_file, "Created SSA_NAME representative ");
print_generic_expr (dump_file, name, 0);
--- 1395,1420 ----
pre_expr rep = expression_for_id (i);
if (rep->kind == NAME)
return PRE_EXPR_NAME (rep);
+ else if (rep->kind == CONSTANT)
+ return PRE_EXPR_CONSTANT (rep);
}
}
break;
}
+
/* If we reached here we couldn't find an SSA_NAME. This can
happen when we've discovered a value that has never appeared in
! the program as set to an SSA_NAME, as the result of phi translation.
! Create one here.
! ??? We should be able to re-use this when we insert the statement
! to compute it. */
name = make_temp_ssa_name (get_expr_type (e), gimple_build_nop (), "pretmp");
VN_INFO_GET (name)->value_id = value_id;
! VN_INFO (name)->valnum = name;
! /* ??? For now mark this SSA name for release by SCCVN. */
! VN_INFO (name)->needs_insertion = true;
add_to_value (value_id, get_or_alloc_expr_for_name (name));
! if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Created SSA_NAME representative ");
print_generic_expr (dump_file, name, 0);
*************** eliminate_bb (dom_walk_data *, basic_blo
*** 4170,4175 ****
--- 4165,4171 ----
if (val != VN_TOP
&& TREE_CODE (val) == SSA_NAME
&& VN_INFO (val)->needs_insertion
+ && VN_INFO (val)->expr != NULL_TREE
&& (sprime = eliminate_insert (&gsi, val)) != NULL_TREE)
eliminate_push_avail (sprime);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-12-13 9:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 9:27 [PATCH] Do not leak SSA names in PRE 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).