diff options
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 60 |
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; |