]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-alias.h (pt_solution_singleton_p): Declare.
authorTom de Vries <tom@codesourcery.com>
Mon, 26 Sep 2011 12:36:56 +0000 (12:36 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 26 Sep 2011 12:36:56 +0000 (12:36 +0000)
2011-09-26  Tom de Vries  <tom@codesourcery.com>

* tree-ssa-alias.h (pt_solution_singleton_p): Declare.
* tree-ssa-structalias.c (pt_solution_singleton_p): New function.
* tree-ssa-ccp.c (fold_builtin_alloca_for_var): Set points-to solution
of new var.

From-SVN: r179193

gcc/ChangeLog
gcc/tree-ssa-alias.h
gcc/tree-ssa-ccp.c
gcc/tree-ssa-structalias.c

index 2d7def04bb908892a26d9ab00d92c262d4b70398..688cb82fc13f7f2d69f2e1dc5653e2dae9b4e164 100644 (file)
@@ -1,3 +1,10 @@
+2011-09-26  Tom de Vries  <tom@codesourcery.com>
+
+       * tree-ssa-alias.h (pt_solution_singleton_p): Declare.
+       * tree-ssa-structalias.c (pt_solution_singleton_p): New function.
+       * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Set points-to solution
+       of new var.
+
 2011-09-26  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/50465
index 75e4303a7ab54aea20688bb73f030ba6d1b9907e..c2ab2113c1e9b1b566e96af5b42a8cbe7bf6da7c 100644 (file)
@@ -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 *);
index fc59d386cad5c65bbb55438d533f8f90ea87dfc7..b5774040e320b255cc434e797a244c0fd93537b2 100644 (file)
@@ -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));
index b2f068a0ac42bcd6fe32cf231be639e2431feaf9..1023acfab19453c8ea1968fe3586c39932dbe545 100644 (file)
@@ -5979,6 +5979,21 @@ pt_solution_empty_p (struct pt_solution *pt)
   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