===================================================================
@@ -1729,6 +1729,17 @@ fold_builtin_alloca_for_var (gimple stmt
array_type = build_array_type_nelts (elem_type, n_elem);
var = create_tmp_var (array_type, NULL);
DECL_ALIGN (var) = align;
+ {
+ struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
+ if (pi != NULL && !pi->pt.anything)
+ {
+ bool singleton_p;
+ unsigned uid;
+ singleton_p = pt_solution_singleton_p (&pi->pt, &uid);
+ gcc_assert (singleton_p);
+ SET_DECL_PT_UID (var, uid);
+ }
+ }
/* Fold alloca to the address of the array. */
return fold_convert (TREE_TYPE (lhs), build_fold_addr_expr (var));
===================================================================
@@ -126,6 +126,7 @@ extern void dump_alias_stats (FILE *);
/* In tree-ssa-structalias.c */
extern unsigned int compute_may_aliases (void);
extern bool pt_solution_empty_p (struct pt_solution *);
+extern bool pt_solution_singleton_p (struct pt_solution *, unsigned *);
extern bool pt_solution_includes_global (struct pt_solution *);
extern bool pt_solution_includes (struct pt_solution *, const_tree);
extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
===================================================================
@@ -5978,6 +5978,21 @@ pt_solution_empty_p (struct pt_solution
return true;
}
+/* Return true if the points-to solution *PT only point to a single var, and
+ return the var uid in *UID. */
+
+bool
+pt_solution_singleton_p (struct pt_solution *pt, unsigned *uid)
+{
+ if (pt->anything || pt->nonlocal || pt->escaped || pt->ipa_escaped
+ || pt->null || pt->vars == NULL
+ || !bitmap_single_bit_set_p (pt->vars))
+ return false;
+
+ *uid = bitmap_first_set_bit (pt->vars);
+ return true;
+}
+
/* Return true if the points-to solution *PT includes global memory. */
bool