From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29360 invoked by alias); 27 Jul 2007 14:18:03 -0000 Received: (qmail 29343 invoked by uid 22791); 27 Jul 2007 14:18:00 -0000 X-Spam-Check-By: sourceware.org Received: from ns.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 27 Jul 2007 14:17:53 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id C534A1223E for ; Fri, 27 Jul 2007 16:17:50 +0200 (CEST) Date: Fri, 27 Jul 2007 14:32:00 -0000 From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH][C] Remove the disregards_inline_limits langhook Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg01984.txt.bz2 Which is only common code apart from - /* We want to inline `extern inline' functions even if this would - violate inlining limits. Some glibc and linux constructs depend on - such functions always being inlined when optimizing. */ ... - return (!flag_really_no_inline && DECL_DECLARED_INLINE_P (fn) - && DECL_EXTERNAL (fn)); in the C frontend. Which is 1) undocumented, 2) not a good idea as it changes inline heuristics if one switches between static inline and extern inline. (Those "depending" on inlining are using always_inline as they should) Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for mainline? Thanks, Richard. 2007-07-27 Richard Guenther * c-objc-common.c (c_disregard_inline_limits): Remove. * c-objc-common.h (c_disregard_inline_limits): Likewise. * cgraphunit.c (cgraph_process_new_functions): Call disregard_inline_limits_p. (cgraph_preserve_function_body_p): Likewise. * ipa-inline.c (compute_inline_parameters): Likewise. * langhooks-def.h (lhd_tree_inlining_disregard_inline_limits): Remove. (LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS): Remove. (LANG_HOOKS_TREE_INLINING_INITIALIZER): Remove initializer for disregard_inline_limits langhook. * langhooks.c (lhd_tree_inlining_disregard_inline_limits): Remove. * langhooks.h (lang_hooks_for_tree_inlining): Remove disregard_inline_limits langhook. * tree-inline.c (disregard_inline_limits_p): New function. * tree-inline.h (disregard_inline_limits_p): Declare. Index: gcc/c-objc-common.c =================================================================== *** gcc.orig/c-objc-common.c 2007-07-27 12:14:41.000000000 +0200 --- gcc/c-objc-common.c 2007-07-27 14:04:31.000000000 +0200 *************** c_missing_noreturn_ok_p (tree decl) *** 50,69 **** return flag_hosted && MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl)); } - /* We want to inline `extern inline' functions even if this would - violate inlining limits. Some glibc and linux constructs depend on - such functions always being inlined when optimizing. */ - - int - c_disregard_inline_limits (tree fn) - { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) != NULL) - return 1; - - return (!flag_really_no_inline && DECL_DECLARED_INLINE_P (fn) - && DECL_EXTERNAL (fn)); - } - int c_cannot_inline_tree_fn (tree *fnp) { --- 50,55 ---- Index: gcc/c-objc-common.h =================================================================== *** gcc.orig/c-objc-common.h 2007-07-26 14:13:38.000000000 +0200 --- gcc/c-objc-common.h 2007-07-27 14:04:46.000000000 +0200 *************** extern void c_initialize_diagnostics (di *** 85,93 **** #undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ c_cannot_inline_tree_fn - #undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS - #define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \ - c_disregard_inline_limits #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN c_dump_tree --- 85,90 ---- Index: gcc/cgraphunit.c =================================================================== *** gcc.orig/cgraphunit.c 2007-07-26 14:13:38.000000000 +0200 --- gcc/cgraphunit.c 2007-07-27 13:59:58.000000000 +0200 *************** cgraph_process_new_functions (void) *** 376,382 **** node->local.self_insns = estimate_num_insns (fndecl, &eni_inlining_weights); node->local.disregard_inline_limits ! = lang_hooks.tree_inlining.disregard_inline_limits (fndecl); /* Inlining characteristics are maintained by the cgraph_mark_inline. */ node->global.insns = node->local.self_insns; --- 376,382 ---- node->local.self_insns = estimate_num_insns (fndecl, &eni_inlining_weights); node->local.disregard_inline_limits ! = disregard_inline_limits_p (fndecl); /* Inlining characteristics are maintained by the cgraph_mark_inline. */ node->global.insns = node->local.self_insns; *************** cgraph_preserve_function_body_p (tree de *** 1247,1253 **** struct cgraph_node *node; if (!cgraph_global_info_ready) return (flag_really_no_inline ! ? lang_hooks.tree_inlining.disregard_inline_limits (decl) : DECL_INLINE (decl)); /* Look if there is any clone around. */ for (node = cgraph_node (decl); node; node = node->next_clone) --- 1247,1253 ---- struct cgraph_node *node; if (!cgraph_global_info_ready) return (flag_really_no_inline ! ? disregard_inline_limits_p (decl) : DECL_INLINE (decl)); /* Look if there is any clone around. */ for (node = cgraph_node (decl); node; node = node->next_clone) Index: gcc/ipa-inline.c =================================================================== *** gcc.orig/ipa-inline.c 2007-07-26 14:13:38.000000000 +0200 --- gcc/ipa-inline.c 2007-07-27 14:00:22.000000000 +0200 *************** compute_inline_parameters (void) *** 1529,1535 **** &eni_inlining_weights); if (node->local.inlinable) node->local.disregard_inline_limits ! = lang_hooks.tree_inlining.disregard_inline_limits (current_function_decl); if (flag_really_no_inline && !node->local.disregard_inline_limits) node->local.inlinable = 0; /* Inlining characteristics are maintained by the cgraph_mark_inline. */ --- 1529,1535 ---- &eni_inlining_weights); if (node->local.inlinable) node->local.disregard_inline_limits ! = disregard_inline_limits_p (current_function_decl); if (flag_really_no_inline && !node->local.disregard_inline_limits) node->local.inlinable = 0; /* Inlining characteristics are maintained by the cgraph_mark_inline. */ Index: gcc/langhooks-def.h =================================================================== *** gcc.orig/langhooks-def.h 2007-07-26 17:24:12.000000000 +0200 --- gcc/langhooks-def.h 2007-07-27 14:07:16.000000000 +0200 *************** extern tree lhd_builtin_function (tree d *** 68,74 **** /* Declarations of default tree inlining hooks. */ extern int lhd_tree_inlining_cannot_inline_tree_fn (tree *); - extern int lhd_tree_inlining_disregard_inline_limits (tree); extern void lhd_initialize_diagnostics (struct diagnostic_context *); extern tree lhd_callgraph_analyze_expr (tree *, int *, tree); --- 68,73 ---- *************** extern void lhd_omp_firstprivatize_type_ *** 133,146 **** /* Tree inlining hooks. */ #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ lhd_tree_inlining_cannot_inline_tree_fn - #define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \ - lhd_tree_inlining_disregard_inline_limits #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \ hook_bool_tree_tree_false #define LANG_HOOKS_TREE_INLINING_INITIALIZER { \ LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN, \ - LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, \ LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P, \ } --- 132,142 ---- Index: gcc/langhooks.c =================================================================== *** gcc.orig/langhooks.c 2007-07-26 17:21:34.000000000 +0200 --- gcc/langhooks.c 2007-07-27 14:04:59.000000000 +0200 *************** lhd_tree_inlining_cannot_inline_tree_fn *** 282,300 **** return 0; } - /* lang_hooks.tree_inlining.disregard_inline_limits is called to - determine whether a function should be considered for inlining even - if it would exceed inlining limits. */ - - int - lhd_tree_inlining_disregard_inline_limits (tree fn) - { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) != NULL) - return 1; - - return 0; - } - /* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree nodes. Returns nonzero if it does not want the usual dumping of the second argument. */ --- 282,287 ---- Index: gcc/langhooks.h =================================================================== *** gcc.orig/langhooks.h 2007-07-26 17:23:59.000000000 +0200 --- gcc/langhooks.h 2007-07-27 14:05:13.000000000 +0200 *************** typedef void (*lang_print_tree_hook) (FI *** 36,42 **** struct lang_hooks_for_tree_inlining { int (*cannot_inline_tree_fn) (tree *); - int (*disregard_inline_limits) (tree); bool (*var_mod_type_p) (tree, tree); }; --- 36,41 ---- Index: gcc/tree-inline.c =================================================================== *** gcc.orig/tree-inline.c 2007-07-27 12:14:41.000000000 +0200 --- gcc/tree-inline.c 2007-07-27 14:04:22.000000000 +0200 *************** inlinable_function_p (tree fn) *** 1913,1918 **** --- 1913,1927 ---- return inlinable; } + /* Return true if we shall disregard inlining limits for the function + FN during inlining. */ + + bool + disregard_inline_limits_p (tree fn) + { + return lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) != NULL_TREE; + } + /* Estimate the cost of a memory move. Use machine dependent word size and take possible memcpy call into account. */ Index: gcc/tree-inline.h =================================================================== *** gcc.orig/tree-inline.h 2007-07-26 14:13:39.000000000 +0200 --- gcc/tree-inline.h 2007-07-27 14:06:29.000000000 +0200 *************** extern void insert_decl_map (copy_body_d *** 130,135 **** --- 130,136 ---- unsigned int optimize_inline_calls (tree); bool tree_inlinable_function_p (tree); + bool disregard_inline_limits_p (tree); tree copy_tree_r (tree *, int *, void *); void clone_body (tree, tree, void *); void save_body (tree, tree *, tree *);