From 8242dd04b79486c5890e599caa9c492eac38c2f8 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 10 May 2011 16:56:19 +0000 Subject: [PATCH] use build_function_type less in c-family and LTO use build_function_type less in c-family and LTO gcc/c-family/ * c-common.c (def_fn_type): Don't call build_function_type, call build_function_type_array or build_varargs_function_type_array instead. (c_common_nodes_and_builtins): Likewise. gcc/lto/ * lto-lang.c (def_fn_type): Don't call build_function_type, call build_function_type_array or build_varargs_function_type_array instead. From-SVN: r173623 --- gcc/c-family/ChangeLog | 7 +++++++ gcc/c-family/c-common.c | 17 +++++++++-------- gcc/lto/ChangeLog | 6 ++++++ gcc/lto/lto-lang.c | 14 +++++++------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9fa7e29b82b..01b6ba7eb2a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2011-05-10 Nathan Froyd + + * c-common.c (def_fn_type): Don't call build_function_type, call + build_function_type_array or build_varargs_function_type_array + instead. + (c_common_nodes_and_builtins): Likewise. + 2011-05-05 Nathan Froyd * c-common.c (c_add_case_label): Omit the loc argument to diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 41cb7176554..a04801ef90d 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4414,7 +4414,8 @@ static tree builtin_types[(int) BT_LAST + 1]; static void def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) { - tree args = NULL, t; + tree t; + tree *args = XALLOCAVEC (tree, n); va_list list; int i; @@ -4425,18 +4426,17 @@ def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) t = builtin_types[a]; if (t == error_mark_node) goto egress; - args = tree_cons (NULL_TREE, t, args); + args[i] = t; } va_end (list); - args = nreverse (args); - if (!var) - args = chainon (args, void_list_node); - t = builtin_types[ret]; if (t == error_mark_node) goto egress; - t = build_function_type (t, args); + if (var) + t = build_varargs_function_type_array (t, n, args); + else + t = build_function_type_array (t, n, args); egress: builtin_types[def] = t; @@ -4931,7 +4931,8 @@ c_common_nodes_and_builtins (void) uintptr_type_node = TREE_TYPE (identifier_global_value (c_get_ident (UINTPTR_TYPE))); - default_function_type = build_function_type (integer_type_node, NULL_TREE); + default_function_type + = build_varargs_function_type_list (integer_type_node, NULL_TREE); ptrdiff_type_node = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE))); unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node); diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index ca1592de5b3..3bc57c954f1 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2011-05-10 Nathan Froyd + + * lto-lang.c (def_fn_type): Don't call build_function_type, call + build_function_type_array or build_varargs_function_type_array + instead. + 2011-05-07 Eric Botcazou * lto-lang.c (global_bindings_p): Return bool. diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index 5872928be0d..5fe89b87d1e 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -433,7 +433,8 @@ handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name), static void def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) { - tree args = NULL, t; + tree t; + tree *args = XALLOCAVEC (tree, n); va_list list; int i; @@ -444,18 +445,17 @@ def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) t = builtin_types[a]; if (t == error_mark_node) goto egress; - args = tree_cons (NULL_TREE, t, args); + args[i] = t; } va_end (list); - args = nreverse (args); - if (!var) - args = chainon (args, void_list_node); - t = builtin_types[ret]; if (t == error_mark_node) goto egress; - t = build_function_type (t, args); + if (var) + t = build_varargs_function_type_array (t, n, args); + else + t = build_function_type_array (t, n, args); egress: builtin_types[def] = t; -- 2.30.2