From 1a2c27e964bb00e2ddbe3e1a265c95adb851402c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 11 Jan 2012 18:47:28 +0000 Subject: tree.h (build_function_decl_skip_args): Add boolean parameter. * tree.h (build_function_decl_skip_args): Add boolean parameter. (build_function_type_skip_args): Delete. * tree.c (build_function_type_skip_args): Make static and add SKIP_RETURN parameter. Fix thinko in the handling of variants. (build_function_decl_skip_args): Add SKIP_RETURN parameter and pass it to build_function_type_skip_args. * cgraph.h (cgraph_function_versioning): Add boolean parameter. (tree_function_versioning): Likewise. * cgraph.c (cgraph_create_virtual_clone): Adjust call to build_function_decl_skip_args. * cgraphunit.c (cgraph_function_versioning): Add SKIP_RETURN parameter and pass it to build_function_decl_skip_args/tree_function_versioning. (cgraph_materialize_clone): Adjust call to tree_function_versioning. * ipa-inline-transform.c (save_inline_function_body): Likewise. * trans-mem.c (ipa_tm_create_version): Likewise. * tree-sra.c (modify_function): Ditto for cgraph_function_versioning. * tree-inline.c (declare_return_variable): Remove always-true test. (tree_function_versioning): Add SKIP_RETURN parameter. If the function returns non-void and SKIP_RETURN, create a void-typed RESULT_DECL. * ipa-split.c (split_function): Skip the return value for the split part if it doesn't return. From-SVN: r183102 --- gcc/tree.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index 76488f7..ec78616 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7567,10 +7567,12 @@ build_function_type (tree value_type, tree arg_types) return t; } -/* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP. */ +/* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP and the + return value if SKIP_RETURN is true. */ -tree -build_function_type_skip_args (tree orig_type, bitmap args_to_skip) +static tree +build_function_type_skip_args (tree orig_type, bitmap args_to_skip, + bool skip_return) { tree new_type = NULL; tree args, new_args = NULL, t; @@ -7579,7 +7581,7 @@ build_function_type_skip_args (tree orig_type, bitmap args_to_skip) for (args = TYPE_ARG_TYPES (orig_type); args && args != void_list_node; args = TREE_CHAIN (args), i++) - if (!bitmap_bit_p (args_to_skip, i)) + if (!args_to_skip || !bitmap_bit_p (args_to_skip, i)) new_args = tree_cons (NULL_TREE, TREE_VALUE (args), new_args); new_reversed = nreverse (new_args); @@ -7597,6 +7599,7 @@ build_function_type_skip_args (tree orig_type, bitmap args_to_skip) When we are asked to remove it, we need to build new FUNCTION_TYPE instead. */ if (TREE_CODE (orig_type) != METHOD_TYPE + || !args_to_skip || !bitmap_bit_p (args_to_skip, 0)) { new_type = build_distinct_type_copy (orig_type); @@ -7610,11 +7613,15 @@ build_function_type_skip_args (tree orig_type, bitmap args_to_skip) TYPE_CONTEXT (new_type) = TYPE_CONTEXT (orig_type); } + if (skip_return) + TREE_TYPE (new_type) = void_type_node; + /* This is a new type, not a copy of an old type. Need to reassociate variants. We can handle everything except the main variant lazily. */ t = TYPE_MAIN_VARIANT (orig_type); - if (orig_type != t) + if (t != orig_type) { + t = build_function_type_skip_args (t, args_to_skip, skip_return); TYPE_MAIN_VARIANT (new_type) = t; TYPE_NEXT_VARIANT (new_type) = TYPE_NEXT_VARIANT (t); TYPE_NEXT_VARIANT (t) = new_type; @@ -7624,33 +7631,40 @@ build_function_type_skip_args (tree orig_type, bitmap args_to_skip) TYPE_MAIN_VARIANT (new_type) = new_type; TYPE_NEXT_VARIANT (new_type) = NULL; } + return new_type; } -/* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP. +/* Build variant of function decl ORIG_DECL skipping ARGS_TO_SKIP and the + return value if SKIP_RETURN is true. Arguments from DECL_ARGUMENTS list can't be removed now, since they are linked by TREE_CHAIN directly. The caller is responsible for eliminating them when they are being duplicated (i.e. copy_arguments_for_versioning). */ tree -build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip) +build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip, + bool skip_return) { tree new_decl = copy_node (orig_decl); tree new_type; new_type = TREE_TYPE (orig_decl); - if (prototype_p (new_type)) - new_type = build_function_type_skip_args (new_type, args_to_skip); + if (prototype_p (new_type) + || (skip_return && !VOID_TYPE_P (TREE_TYPE (new_type)))) + new_type + = build_function_type_skip_args (new_type, args_to_skip, skip_return); TREE_TYPE (new_decl) = new_type; /* For declarations setting DECL_VINDEX (i.e. methods) we expect first argument to be THIS pointer. */ - if (bitmap_bit_p (args_to_skip, 0)) + if (args_to_skip && bitmap_bit_p (args_to_skip, 0)) DECL_VINDEX (new_decl) = NULL_TREE; /* When signature changes, we need to clear builtin info. */ - if (DECL_BUILT_IN (new_decl) && !bitmap_empty_p (args_to_skip)) + if (DECL_BUILT_IN (new_decl) + && args_to_skip + && !bitmap_empty_p (args_to_skip)) { DECL_BUILT_IN_CLASS (new_decl) = NOT_BUILT_IN; DECL_FUNCTION_CODE (new_decl) = (enum built_in_function) 0; -- cgit v1.1