public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH][C] Remove the disregards_inline_limits langhook
Date: Fri, 27 Jul 2007 14:32:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0707271619350.6492@s68.fhfr.qr> (raw)


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  <rguenther@suse.de>

	* 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 *);

             reply	other threads:[~2007-07-27 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27 14:32 Richard Guenther [this message]
2007-08-11 19:00 ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707271619350.6492@s68.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).