From patchwork Thu Mar 28 13:47:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Dos Reis X-Patchwork-Id: 232030 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6A67D2C00B8 for ; Fri, 29 Mar 2013 00:48:17 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=RCGHQTc5KG6BwalAsVX//z3in+BC+Xo8l+KlF3WJCX1gf8wJB+ Mhw3l1q+B3VZbBeFDeg64oxCMfPZvWf9p6D2P/Q14aEhvxkgZl3eoDvYMFnwvTNu 6uNZlcplsqfDeGnhOJamkmNop9GeqfTwgReAx94KpP965XRKryAm4etrs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=Ut3zqqq6oYczbktqYa/GMvdtfkA=; b=NwfQrLgPbw3eTd1D/miG 8eDEgaQJR5Nq6fZEbKJnvoD3m63jmGcess4+iXfG8PRYt7TXBAqfiHJEUOdXJN9S flWrVSLf2w8neQS5O9jSoo0hXIQOtbVrSszO4CoxaM7JxYi0gDNHiWDuNvyb4+BA Ch6oVsCER/Y1QL+z8iaJLaA= Received: (qmail 7274 invoked by alias); 28 Mar 2013 13:48:00 -0000 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 Received: (qmail 7229 invoked by uid 89); 28 Mar 2013 13:47:51 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from www.axiomatics.org (HELO mail.axiomatics.org) (66.228.53.191) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 28 Mar 2013 13:47:48 +0000 Received: by mail.axiomatics.org (Postfix, from userid 1000) id 52404ED4F; Thu, 28 Mar 2013 08:47:46 -0500 (CDT) From: Gabriel Dos Reis To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: C++ PATCH: use C++ semantics for inline functions (defined in headers) Date: Thu, 28 Mar 2013 08:47:46 -0500 Message-ID: <87a9pnbpq5.fsf@euclid.axiomatics.org> Lines: 104 MIME-Version: 1.0 C++ has a much more predictable semantics for inline functions, so we no longer need to define them (especially in header files) with the 'static' specifier. The upshot is that when the compiler fails to inline a call in a given translation unit, it keeps only one copy in the entire program, instead of multiple copies (as the 'static' specifier would have implied.) With this patch, there is 2K reduction in size for cc1plus. Applying to trunk. Tested on an x86_64-suse-linux. -- Gaby 2013-03-28 Gabriel Dos Reis * cp-tree.h (next_aggr_init_expr_arg): Remove static specifier. (first_aggr_init_expr): Likewise. (more_aggr_init_expr_args_p): Likewise. (type_of_this_parm): Likewise. (class_of_this_parm): Likewise. * name-lookup.h (get_global_value_if_present): Likewise. (is_typename_at_global_scope): Likewise. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 197194) +++ cp-tree.h (working copy) @@ -3026,7 +3026,7 @@ /* Initialize the abstract argument list iterator object ITER with the arguments from AGGR_INIT_EXPR node EXP. */ -static inline void +inline void init_aggr_init_expr_arg_iterator (tree exp, aggr_init_expr_arg_iterator *iter) { @@ -3037,7 +3037,7 @@ /* Return the next argument from abstract argument list iterator object ITER, and advance its state. Return NULL_TREE if there are no more arguments. */ -static inline tree +inline tree next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter) { tree result; @@ -3052,7 +3052,7 @@ past and return the first argument. Useful in for expressions, e.g. for (arg = first_aggr_init_expr_arg (exp, &iter); arg; arg = next_aggr_init_expr_arg (&iter)) */ -static inline tree +inline tree first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter) { init_aggr_init_expr_arg_iterator (exp, iter); @@ -3061,7 +3061,7 @@ /* Test whether there are more arguments in abstract argument list iterator ITER, without changing its state. */ -static inline bool +inline bool more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) { return (iter->i < iter->n); @@ -4905,7 +4905,7 @@ /* Return the type of the `this' parameter of FNTYPE. */ -static inline tree +inline tree type_of_this_parm (const_tree fntype) { function_args_iterator iter; @@ -4916,7 +4916,7 @@ /* Return the class of the `this' parameter of FNTYPE. */ -static inline tree +inline tree class_of_this_parm (const_tree fntype) { return TREE_TYPE (type_of_this_parm (fntype)); Index: name-lookup.h =================================================================== --- name-lookup.h (revision 197194) +++ name-lookup.h (working copy) @@ -347,7 +347,7 @@ /* Set *DECL to the (non-hidden) declaration for ID at global scope, if present and return true; otherwise return false. */ -static inline bool +inline bool get_global_value_if_present (tree id, tree *decl) { tree global_value = namespace_binding (id, global_namespace); @@ -358,7 +358,7 @@ /* True is the binding of IDENTIFIER at global scope names a type. */ -static inline bool +inline bool is_typename_at_global_scope (tree id) { tree global_value = namespace_binding (id, global_namespace);