aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2005-10-03 08:43:45 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2005-10-03 08:43:45 +0000
commit0b494699b41f22f5392c7f2f5f4683e96b8fc0cd (patch)
tree12db18961c42def11ca08dfd5229612afd843c31 /gcc/gimplify.c
parent644cb69f803dc904c271885272e70f032ce56a97 (diff)
downloadgcc-0b494699b41f22f5392c7f2f5f4683e96b8fc0cd.zip
gcc-0b494699b41f22f5392c7f2f5f4683e96b8fc0cd.tar.gz
gcc-0b494699b41f22f5392c7f2f5f4683e96b8fc0cd.tar.bz2
gimplify.c (find_single_pointer_decl_1): New static function.
* gimplify.c (find_single_pointer_decl_1): New static function. (find_single_pointer_decl): New static function. (internal_get_tmp_var): For a formal variable, set restrict base information if appropriate. * alias.c (find_base_decl): If a VAR_DECL has a restrict base, return it. * tree.h (DECL_BASED_ON_RESTRICT_P): Define. (DECL_GET_RESTRICT_BASE): Define. (SET_DECL_RESTRICT_BASE): Define. (decl_restrict_base_lookup): Declare. (decl_restrict_base_insert): Declare. (struct tree_decl_with_vis): Add based_on_restrict_p field. * tree.c (restrict_base_for_decl): New static variable. (init_ttree): Initialize restrict_base_for_decl. (copy_node_stat): Copy restrict base information. (decl_restrict_base_lookup): New function. (decl_restrict_base_insert): New function. (print_restrict_base_statistics): New static function. (dump_tree_statistics): Call print_restrict_base_statistics. From-SVN: r104890
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e5d50e2..7047918 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -298,6 +298,48 @@ create_artificial_label (void)
return lab;
}
+/* Subroutine for find_single_pointer_decl. */
+
+static tree
+find_single_pointer_decl_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+ void *data)
+{
+ tree *pdecl = (tree *) data;
+
+ if (DECL_P (*tp) && POINTER_TYPE_P (TREE_TYPE (*tp)))
+ {
+ if (*pdecl)
+ {
+ /* We already found a pointer decl; return anything other
+ than NULL_TREE to unwind from walk_tree signalling that
+ we have a duplicate. */
+ return *tp;
+ }
+ *pdecl = *tp;
+ }
+
+ return NULL_TREE;
+}
+
+/* Find the single DECL of pointer type in the tree T and return it.
+ If there are zero or more than one such DECLs, return NULL. */
+
+static tree
+find_single_pointer_decl (tree t)
+{
+ tree decl = NULL_TREE;
+
+ if (walk_tree (&t, find_single_pointer_decl_1, &decl, NULL))
+ {
+ /* find_single_pointer_decl_1 returns a non-zero value, causing
+ walk_tree to return a non-zero value, to indicate that it
+ found more than one pointer DECL. */
+ return NULL_TREE;
+ }
+
+ return decl;
+}
+
/* Create a new temporary name with PREFIX. Returns an identifier. */
static GTY(()) unsigned int tmp_var_id_num;
@@ -470,6 +512,24 @@ internal_get_tmp_var (tree val, tree *pre_p, tree *post_p, bool is_formal)
t = lookup_tmp_var (val, is_formal);
+ if (is_formal)
+ {
+ tree u = find_single_pointer_decl (val);
+
+ if (u && TREE_CODE (u) == VAR_DECL && DECL_BASED_ON_RESTRICT_P (u))
+ u = DECL_GET_RESTRICT_BASE (u);
+ if (u && TYPE_RESTRICT (TREE_TYPE (u)))
+ {
+ if (DECL_BASED_ON_RESTRICT_P (t))
+ gcc_assert (u == DECL_GET_RESTRICT_BASE (t));
+ else
+ {
+ DECL_BASED_ON_RESTRICT_P (t) = 1;
+ SET_DECL_RESTRICT_BASE (t, u);
+ }
+ }
+ }
+
if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
DECL_COMPLEX_GIMPLE_REG_P (t) = 1;