aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2004-06-26 21:11:23 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2004-06-26 17:11:23 -0400
commit350fae6628af14c2e760694d39baec5f7858057c (patch)
treeec365de72a39a5ef2d0a252b8496e9199f69fb3d /gcc/tree-inline.c
parent6573a10434b3aa2784f052d6ffc3905d8490464e (diff)
downloadgcc-350fae6628af14c2e760694d39baec5f7858057c.zip
gcc-350fae6628af14c2e760694d39baec5f7858057c.tar.gz
gcc-350fae6628af14c2e760694d39baec5f7858057c.tar.bz2
c-common.c (c_safe_from_p, [...]): Deleted.
2004-06-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * c-common.c (c_safe_from_p, c_walk_subtrees): Deleted. * c-common.def (DECL_STMT): Remove. * c-common.h (DECL_STMT_DECL): Deleted. (COMPOUNT_LITERAL_EXPR_DECL): Use DECL_EXPR_DECL. (c_safe_from_p, c_walk_subtrees): Deleted. * c-decl.c, c-parse.in, c-pretty-print.c: DECL_STMT now DECL_EXPR. * c-dump.c (c_dump_tree, case DECL_STMT): Deleted. * c-gimplify.c (gimplify_decl_stmt): Deleted. (gimplify_compound_literal_expr): Use DECL_EXPR_DECL and gimplify_and_add. (c_gimplify_expr, case DECL_EXPR): New case. (c_gimplify_expr, case DECL_STMT): Deleted. * c-lang.c (LANG_HOOKS_SAFE_FROM_P): Likewise. (LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Likewise. * expr.c (safe_from_p, case 's'): New case. * gimplify.c (gimplify_decl_expr): New function. (gimplify_expr, case DECL_EXPR): New case. * tree-inline.c (walk_tree): Walk into all fields of a type and decl only if they are in a DECL_EXPR. (mark_local_for_remap_r): Minor code cleanup. * tree-outof-ssa.c (discover_nonconstant_array_refs_r): Add else. * tree.c (has_cleanups, case DECL_EXPR): New case. * tree.def (DECL_EXPR): New code. * tree.h (DECL_EXPR_DECL): New macro. * objc/objc-lang.c (LANG_HOOKS_SAFE_FROM_P): Deleted. From-SVN: r83721
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c211
1 files changed, 105 insertions, 106 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index e9bb300..ac52562 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2032,10 +2032,63 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
if (result || ! walk_subtrees)
return result;
- if (code != EXIT_BLOCK_EXPR
- && code != SAVE_EXPR
- && code != BIND_EXPR
- && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
+ /* If this is a DECL_EXPR, walk into various fields of the type or variable
+ that it's defining. We only want to walk into these fields of a decl
+ or type in this case.
+
+ ??? Precisely which fields of types that we are supposed to walk in
+ this case vs. the normal case aren't well defined. */
+ if (code == DECL_EXPR
+ && TREE_CODE (DECL_EXPR_DECL (*tp)) != ERROR_MARK
+ && TREE_CODE (TREE_TYPE (DECL_EXPR_DECL (*tp))) != ERROR_MARK)
+ {
+ tree decl = DECL_EXPR_DECL (*tp);
+ tree type = TREE_TYPE (decl);
+
+ /* Walk into fields of the DECL if it's not a type, then into fields
+ of the type in both cases. */
+
+ if (TREE_CODE (decl) != TYPE_DECL
+ && TREE_CODE (decl) != FIELD_DECL && TREE_CODE (decl) != PARM_DECL)
+ {
+ WALK_SUBTREE (DECL_INITIAL (decl));
+ WALK_SUBTREE (DECL_SIZE (decl));
+ WALK_SUBTREE (DECL_SIZE_UNIT (decl));
+ }
+
+ /* First do the common fields via recursion, then the fields we only
+ do when we are declaring the type or object. */
+ WALK_SUBTREE (type);
+ WALK_SUBTREE (TYPE_SIZE (type));
+ WALK_SUBTREE (TYPE_SIZE_UNIT (type));
+
+ /* If this is a record type, also walk the fields. */
+ if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
+ || TREE_CODE (type) == QUAL_UNION_TYPE)
+ {
+ tree field;
+
+ for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+ {
+ /* We'd like to look at the type of the field, but we can easily
+ get infinite recursion. So assume it's pointed to elsewhere
+ in the tree. Also, ignore things that aren't fields. */
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+
+ WALK_SUBTREE (DECL_FIELD_OFFSET (field));
+ WALK_SUBTREE (DECL_SIZE (field));
+ WALK_SUBTREE (DECL_SIZE_UNIT (field));
+ if (TREE_CODE (type) == QUAL_UNION_TYPE)
+ WALK_SUBTREE (DECL_QUALIFIER (field));
+ }
+ }
+ }
+
+ else if (code != EXIT_BLOCK_EXPR
+ && code != SAVE_EXPR
+ && code != BIND_EXPR
+ && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
{
int i, len;
@@ -2068,24 +2121,8 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
#endif
}
- /* Look inside the sizes of decls, but we don't ever use the values for
- FIELD_DECL and RESULT_DECL, so ignore them. */
- else if (TREE_CODE_CLASS (code) == 'd'
- && code != FIELD_DECL && code != RESULT_DECL)
- {
- WALK_SUBTREE (DECL_SIZE (*tp));
- WALK_SUBTREE (DECL_SIZE_UNIT (*tp));
- WALK_SUBTREE_TAIL (TREE_TYPE (*tp));
- }
else
{
- if (TREE_CODE_CLASS (code) == 't')
- {
- WALK_SUBTREE (TYPE_SIZE (*tp));
- WALK_SUBTREE (TYPE_SIZE_UNIT (*tp));
- /* Also examine various special fields, below. */
- }
-
/* Not one of the easy cases. We must explicitly go through the
children. */
switch (code)
@@ -2107,12 +2144,6 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
above. */
break;
- case POINTER_TYPE:
- case REFERENCE_TYPE:
- case COMPLEX_TYPE:
- WALK_SUBTREE_TAIL (TREE_TYPE (*tp));
- break;
-
case TREE_LIST:
WALK_SUBTREE (TREE_VALUE (*tp));
WALK_SUBTREE_TAIL (TREE_CHAIN (*tp));
@@ -2140,6 +2171,44 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
case CONSTRUCTOR:
WALK_SUBTREE_TAIL (CONSTRUCTOR_ELTS (*tp));
+ case EXIT_BLOCK_EXPR:
+ WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 1));
+
+ case SAVE_EXPR:
+ WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0));
+
+ case BIND_EXPR:
+ {
+ tree decl;
+ for (decl = BIND_EXPR_VARS (*tp); decl; decl = TREE_CHAIN (decl))
+ {
+ /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk
+ into declarations that are just mentioned, rather than
+ declared; they don't really belong to this part of the tree.
+ And, we can see cycles: the initializer for a declaration
+ can refer to the declaration itself. */
+ WALK_SUBTREE (DECL_INITIAL (decl));
+ WALK_SUBTREE (DECL_SIZE (decl));
+ WALK_SUBTREE (DECL_SIZE_UNIT (decl));
+ WALK_SUBTREE (TREE_TYPE (decl));
+ }
+ WALK_SUBTREE_TAIL (BIND_EXPR_BODY (*tp));
+ }
+
+ case STATEMENT_LIST:
+ {
+ tree_stmt_iterator i;
+ for (i = tsi_start (*tp); !tsi_end_p (i); tsi_next (&i))
+ WALK_SUBTREE (*tsi_stmt_ptr (i));
+ }
+ break;
+
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ case COMPLEX_TYPE:
+ WALK_SUBTREE_TAIL (TREE_TYPE (*tp));
+ break;
+
case METHOD_TYPE:
WALK_SUBTREE (TYPE_METHOD_BASETYPE (*tp));
@@ -2148,38 +2217,14 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
case FUNCTION_TYPE:
WALK_SUBTREE (TREE_TYPE (*tp));
{
- tree arg = TYPE_ARG_TYPES (*tp);
+ tree arg;
/* We never want to walk into default arguments. */
- for (; arg; arg = TREE_CHAIN (arg))
+ for (arg = TYPE_ARG_TYPES (*tp); arg; arg = TREE_CHAIN (arg))
WALK_SUBTREE (TREE_VALUE (arg));
}
break;
- case RECORD_TYPE:
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- {
- tree field;
-
- for (field = TYPE_FIELDS (*tp); field; field = TREE_CHAIN (field))
- {
- /* We would like to look at the type of the field, but we
- can easily get infinite recursion. So assume it's
- pointed to elsewhere in the tree. Also, ignore things that
- aren't fields. */
- if (TREE_CODE (field) != FIELD_DECL)
- continue;
-
- WALK_SUBTREE (DECL_FIELD_OFFSET (field));
- WALK_SUBTREE (DECL_SIZE (field));
- WALK_SUBTREE (DECL_SIZE_UNIT (field));
- if (code == QUAL_UNION_TYPE)
- WALK_SUBTREE (DECL_QUALIFIER (field));
- }
- }
- break;
-
case ARRAY_TYPE:
/* Don't follow this nodes's type if a pointer for fear that we'll
have infinite recursion. Those types are uninteresting anyway. */
@@ -2200,38 +2245,6 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, void *htab_)
WALK_SUBTREE (TREE_TYPE (*tp));
WALK_SUBTREE_TAIL (TYPE_OFFSET_BASETYPE (*tp));
- case EXIT_BLOCK_EXPR:
- WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 1));
-
- case SAVE_EXPR:
- WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0));
-
- case BIND_EXPR:
- {
- tree decl;
- for (decl = BIND_EXPR_VARS (*tp); decl; decl = TREE_CHAIN (decl))
- {
- /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk
- into declarations that are just mentioned, rather than
- declared; they don't really belong to this part of the tree.
- And, we can see cycles: the initializer for a declaration
- can refer to the declaration itself. */
- WALK_SUBTREE (DECL_INITIAL (decl));
- WALK_SUBTREE (DECL_SIZE (decl));
- WALK_SUBTREE (DECL_SIZE_UNIT (decl));
- WALK_SUBTREE (TREE_TYPE (decl));
- }
- WALK_SUBTREE_TAIL (BIND_EXPR_BODY (*tp));
- }
-
- case STATEMENT_LIST:
- {
- tree_stmt_iterator i;
- for (i = tsi_start (*tp); !tsi_end_p (i); tsi_next (&i))
- WALK_SUBTREE (*tsi_stmt_ptr (i));
- }
- break;
-
default:
/* ??? This could be a language-defined node. We really should make
a hook for it, but right now just ignore it. */
@@ -2358,34 +2371,20 @@ static tree
mark_local_for_remap_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
void *data)
{
- tree t = *tp;
inline_data *id = (inline_data *) data;
- tree decl;
/* Don't walk into types. */
- if (TYPE_P (t))
- {
- *walk_subtrees = 0;
- return NULL_TREE;
- }
-
- if (TREE_CODE (t) == LABEL_EXPR)
- decl = TREE_OPERAND (t, 0);
- else
- /* We don't need to handle anything else ahead of time. */
- decl = NULL_TREE;
+ if (TYPE_P (*tp))
+ *walk_subtrees = 0;
- if (decl)
+ else if (TREE_CODE (*tp) == LABEL_EXPR)
{
- tree copy;
-
- /* Make a copy. */
- copy = copy_decl_for_inlining (decl,
- DECL_CONTEXT (decl),
- DECL_CONTEXT (decl));
+ tree decl = TREE_OPERAND (*tp, 0);
- /* Remember the copy. */
- insert_decl_map (id, decl, copy);
+ /* Copy the decl and remember the copy. */
+ insert_decl_map (id, decl,
+ copy_decl_for_inlining (decl, DECL_CONTEXT (decl),
+ DECL_CONTEXT (decl)));
}
return NULL_TREE;