aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-structalias.c
diff options
context:
space:
mode:
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)
{