aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-structalias.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-07-01 12:27:33 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-07-01 12:27:33 +0000
commit14c41b9bb9c2918a0727d6dd43b96c2df0b3bcf8 (patch)
tree1817c538d837f3cc63a2849dd1c687fef88ed18d /gcc/tree-ssa-structalias.c
parentf6e0880aa00a47be074e875443587a7665f68071 (diff)
downloadgcc-14c41b9bb9c2918a0727d6dd43b96c2df0b3bcf8.zip
gcc-14c41b9bb9c2918a0727d6dd43b96c2df0b3bcf8.tar.gz
gcc-14c41b9bb9c2918a0727d6dd43b96c2df0b3bcf8.tar.bz2
re PR tree-optimization/19831 (Missing DSE/malloc/free optimization)
2009-07-01 Richard Guenther <rguenther@suse.de> PR tree-optimization/19831 * tree-ssa-dce.c (propagate_necessity): Calls to functions that only act as barriers do not make any previous stores necessary. * tree-ssa-structalias.c (handle_lhs_call): Delay making HEAP variables global, do not add a constraint from nonlocal. (find_func_aliases): Handle escapes through return statements. (compute_points_to_sets): Make escaped HEAP variables global. * gcc.dg/tree-ssa/20041122-1.c: Enable TBAA, scan FRE dump, make allocated memory escape. Un-XFAIL. * gcc.dg/vect/pr21591.c: Make allocated memory escape. * gcc.dg/vect/pr31699.c: Likewise. * gcc.dg/tree-ssa/ssa-dce-7.c: New testcase. libmudflap/ * testsuite/libmudflap.c/fail11-frag.c: Make allocated memory escape. * testsuite/libmudflap.c/fail12-frag.c: Likewise. * testsuite/libmudflap.c/fail16-frag.c: Likewise. * testsuite/libmudflap.c/fail31-frag.c: Likewise. From-SVN: r149140
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r--gcc/tree-ssa-structalias.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index ad5482a..84edf00 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -3473,7 +3473,9 @@ handle_lhs_call (tree lhs, int flags, VEC(ce_s, heap) *rhsc)
{
varinfo_t vi;
vi = make_constraint_from_heapvar (get_vi_for_tree (lhs), "HEAP");
- make_copy_constraint (vi, nonlocal_id);
+ /* We delay marking allocated storage global until we know if
+ it escapes. */
+ vi->is_global_var = 0;
}
else if (VEC_length (ce_s, rhsc) > 0)
{
@@ -3910,6 +3912,13 @@ find_func_aliases (gimple origt)
{
make_escape_constraint (gimple_assign_rhs1 (t));
}
+ /* Handle escapes through return. */
+ else if (gimple_code (t) == GIMPLE_RETURN
+ && gimple_return_retval (t) != NULL_TREE
+ && could_have_pointers (gimple_return_retval (t)))
+ {
+ make_escape_constraint (gimple_return_retval (t));
+ }
/* Handle asms conservatively by adding escape constraints to everything. */
else if (gimple_code (t) == GIMPLE_ASM)
{
@@ -5350,6 +5359,7 @@ compute_points_to_sets (void)
struct scc_info *si;
basic_block bb;
unsigned i;
+ varinfo_t vi;
timevar_push (TV_TREE_PTA);
@@ -5447,6 +5457,13 @@ compute_points_to_sets (void)
points-to solution queries. */
cfun->gimple_df->escaped.escaped = 0;
+ /* Mark escaped HEAP variables as global. */
+ for (i = 0; VEC_iterate (varinfo_t, varmap, i, vi); ++i)
+ if (vi->is_heap_var
+ && !vi->is_global_var)
+ vi->is_global_var = pt_solution_includes (&cfun->gimple_df->escaped,
+ vi->decl);
+
/* Compute the points-to sets for pointer SSA_NAMEs. */
for (i = 0; i < num_ssa_names; ++i)
{