From patchwork Tue May 10 13:14:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 94988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 50B78B6EF3 for ; Tue, 10 May 2011 23:14:57 +1000 (EST) Received: (qmail 26114 invoked by alias); 10 May 2011 13:14:55 -0000 Received: (qmail 26102 invoked by uid 22791); 10 May 2011 13:14:53 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 13:14:39 +0000 Received: (qmail 18355 invoked from network); 10 May 2011 13:14:39 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 13:14:39 -0000 Date: Tue, 10 May 2011 06:14:38 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: dnovillo@google.com Subject: [PATCH] use build_function_type less in c-family and LTO Message-ID: <20110510131438.GT23480@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org As $SUBJECT suggests. Eradicating build_function_type from the C FE entirely will take a bit more work. The lto change is included because def_fn_type there is clearly a copy of the C version; I am going to assume that given other approvals of copy-paste code, this one is obvious. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan gcc/c-family/ * c-common.c (def_fn_type): Don't call build_function_type, call build_function_type_vec or build_varargs_function_type_vec 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_vec or build_varargs_function_type_vec instead. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 41cb717..a04801e 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/lto-lang.c b/gcc/lto/lto-lang.c index 5872928..5fe89b8 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;