params.def: Introduce parameter max-inline-insns-rtl for a separate limit for the...
authorKurt Garloff <garloff@suse.de>
Sun, 2 Mar 2003 21:18:16 +0000 (21:18 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Sun, 2 Mar 2003 21:18:16 +0000 (21:18 +0000)
2003-03-02  Kurt Garloff  <garloff@suse.de>

* params.def: Introduce parameter max-inline-insns-rtl for
a separate limit for the RTL inliner.
* params.h: Likewise.
* integrate.c (function_cannot_inline_p): Use it.
* toplev.c (decode_f_option): Set multiple parameters
controlling inlining with -finline-limit.
* params.def: Fix orthographic and typographic errors.
* doc/invoke.texi: Document parameters controlling inlining
and the way -finline-limit sets multiple of them.

* tree.h (struct tree_decl): Introduce inlined_function_flag,
recording whether the function became eligible for inlining
by a compiler flag rather than the declaration.
Provide DID_INLINE_FUNC macro to access it.
* c-decl.c (grokdeclarator): Set DID_INLINE_FUNC.
* cp/decl.c (grokfndecl): Likewise.
* toplev.c (rest_of_compilation): Likewise.
* cp/optimize (maybe_clone_body): Copy DID_INLINE_FUNC.
* print-tree.c (print_node): Report it.
* params.def: Introduce new max-inline-insns-auto limit.
* params.h: Likewise.
* tree-inline.c (inlinable_function_p): Apply it to functions
with DID_INLINE_FUNC set.
* toplev.c (decode_f_option): Initialize it from -finline-limit
value.
* doc/invoke.texi: Document new parameter.

From-SVN: r63688

12 files changed:
gcc/ChangeLog
gcc/c-decl.c
gcc/cp/decl.c
gcc/cp/optimize.c
gcc/doc/invoke.texi
gcc/integrate.c
gcc/params.def
gcc/params.h
gcc/print-tree.c
gcc/toplev.c
gcc/tree-inline.c
gcc/tree.h

index a421151031557fdf22b1cd06eeb0eb2740bc7374..898cdcd86eb048dbf986d385d715a3e45f6817f4 100644 (file)
@@ -1,3 +1,32 @@
+2003-03-02  Kurt Garloff  <garloff@suse.de>
+
+       * params.def: Introduce parameter max-inline-insns-rtl for
+       a separate limit for the RTL inliner.
+       * params.h: Likewise.
+       * integrate.c (function_cannot_inline_p): Use it.
+       * toplev.c (decode_f_option): Set multiple parameters 
+       controlling inlining with -finline-limit.
+       * params.def: Fix orthographic and typographic errors.
+       * doc/invoke.texi: Document parameters controlling inlining
+       and the way -finline-limit sets multiple of them.
+
+       * tree.h (struct tree_decl): Introduce inlined_function_flag,
+       recording whether the function became eligible for inlining
+       by a compiler flag rather than the declaration.
+       Provide DID_INLINE_FUNC macro to access it.
+       * c-decl.c (grokdeclarator): Set DID_INLINE_FUNC.
+       * cp/decl.c (grokfndecl): Likewise.
+       * toplev.c (rest_of_compilation): Likewise.
+       * cp/optimize (maybe_clone_body): Copy DID_INLINE_FUNC.
+       * print-tree.c (print_node): Report it.
+       * params.def: Introduce new max-inline-insns-auto limit.
+       * params.h: Likewise.
+       * tree-inline.c (inlinable_function_p): Apply it to functions
+       with DID_INLINE_FUNC set.
+       * toplev.c (decode_f_option): Initialize it from -finline-limit
+       value.
+       * doc/invoke.texi: Document new parameter.
+
 2003-03-02  Geoffrey Keating  <geoffk@apple.com>
 
        * fix-header.c (read_scan_file): Don't reference simplify_path.
index a5bb317bde7c524599152be83daeef7b8ce20558..4779406277f13974abd9f5216b20ee05df00a958 100644 (file)
@@ -4567,6 +4567,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
           needed, and let dwarf2 know that the function is inlinable.  */
        else if (flag_inline_trees == 2 && initialized)
          {
+           if (!DECL_INLINE (decl))
+               DID_INLINE_FUNC (decl) = 1;
            DECL_INLINE (decl) = 1;
            DECL_DECLARED_INLINE_P (decl) = 0;
          }
index b2c2577fa49e666dc618035224fdef65e208479a..2f29c48175663616b4405b7a9afc1756138cd4c9 100644 (file)
@@ -8955,13 +8955,19 @@ grokfndecl (tree ctype,
       DECL_NOT_REALLY_EXTERN (decl) = 1;
     }
 
+  DID_INLINE_FUNC (decl) = 0;
   /* If the declaration was declared inline, mark it as such.  */
   if (inlinep)
     DECL_DECLARED_INLINE_P (decl) = 1;
   /* We inline functions that are explicitly declared inline, or, when
      the user explicitly asks us to, all functions.  */
-  if (DECL_DECLARED_INLINE_P (decl) || flag_inline_trees == 2)
+  if (DECL_DECLARED_INLINE_P (decl))
     DECL_INLINE (decl) = 1;
+  if (flag_inline_trees == 2 && !DECL_INLINE (decl))
+    {
+      DID_INLINE_FUNC (decl) = 1;
+      DECL_INLINE (decl) = 1;
+    }
 
   DECL_EXTERNAL (decl) = 1;
   if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
@@ -14217,6 +14223,7 @@ start_method (tree declspecs, tree declarator, tree attrlist)
 
   DECL_DECLARED_INLINE_P (fndecl) = 1;
 
+  DID_INLINE_FUNC (fndecl) = 0;
   if (flag_default_inline)
     DECL_INLINE (fndecl) = 1;
 
index 8f08c9ac22b006a7526f87ae484c597d3ae12226..d461b0d08b5c3d83d63abb4d249c44db09b01fe2 100644 (file)
@@ -159,6 +159,7 @@ maybe_clone_body (tree fn)
       /* Update CLONE's source position information to match FN's.  */
       DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn);
       DECL_INLINE (clone) = DECL_INLINE (fn);
+      DID_INLINE_FUNC (clone) = DID_INLINE_FUNC (fn);
       DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn);
       DECL_COMDAT (clone) = DECL_COMDAT (fn);
       DECL_WEAK (clone) = DECL_WEAK (fn);
index 22d0ffc62f6d95797c576f472266070fa7f75dc3..54a283c287dff6341c12caa543602177ca86b0a5 100644 (file)
@@ -3643,6 +3643,28 @@ the compilation faster and less code will be inlined (which presumably
 means slower programs).  This option is particularly useful for programs that
 use inlining heavily such as those based on recursive templates with C++.
 
+Inlining is actually controlled by a number of parameters, which may be
+specified individually by using @option{--param @var{name}=@var{value}}.
+The @option{-finline-limit=@var{n}} option sets some of these parameters 
+as follows:
+
+@table @gcctabopt
+ @item max-inline-insns
+  is set to @var{n}.
+ @item max-inline-insns-single
+  is set to @var{n}/2.
+ @item max-inline-insns-single-auto
+  is set to @var{n}/2.
+ @item min-inline-insns
+  is set to 130 or @var{n}/4, whichever is smaller.
+ @item max-inline-insns-rtl
+  is set to @var{n}.
+@end table
+
+Using @option{-finline-limit=600} thus results in the default settings
+for these parameters.  See below for a documentation of the individual
+parameters controlling inlining.
+
 @emph{Note:} pseudo instruction represents, in this particular context, an
 abstract measurement of function's size.  In no way, it represents a count
 of assembly instructions and as such its exact meaning might change from one
@@ -4466,10 +4488,53 @@ before flushing the current state and starting over.  Large functions
 with few branches or calls can create excessively large lists which
 needlessly consume memory and resources.
 
+@item max-inline-insns-single
+Several parameters control the tree inliner used in gcc.
+This number sets the maximum number of instructions (counted in gcc's
+internal representation) in a single function that the tree inliner 
+will consider for inlining.  This only affects functions declared
+inline and methods implemented in a class declaration (C++).
+The default value is 300.
+
+@item max-inline-insns-auto
+When you use @option{-finline-functions} (included in @option{-O3}),
+a lot of functions that would otherwise not be considered for inlining
+by the compiler will be investigated.  To those functions, a different
+(more restrictive) limit compared to functions declared inline can
+be applied.
+The default value is 300.
+
 @item max-inline-insns
-If an function contains more than this many instructions, it
-will not be inlined.  This option is precisely equivalent to
-@option{-finline-limit}.
+The tree inliner does decrease the allowable size for single functions 
+to be inlined after we already inlined the number of instructions
+given here by repeated inlining.  This number should be a factor of 
+two or more larger than the single function limit.
+Higher numbers result in better runtime performance, but incur higher
+compile-time resource (CPU time, memory) requirements and result in
+larger binaries.  Very high values are not advisable, as too large
+binaries may adversely affect runtime performance.
+The default value is 600.
+
+@item max-inline-slope
+After exceeding the maximum number of inlined instructions by repeated
+inlining, a linear function is used to decrease the allowable size
+for single functions.  The slope of that function is the negative
+reciprocal of the number specified here.
+The default value is 32.
+
+@item min-inline-insns
+The repeated inlining is throttled more and more by the linear function
+after exceeding the limit.  To avoid too much throttling, a minimum for
+this function is specified here to allow repeated inlining for very small
+functions even when a lot of repeated inlining already has been done.
+The default value is 130.
+
+@item max-inline-insns-rtl
+For languages that use the RTL inliner (this happens at a later stage
+than tree inlining), you can set the maximum allowable size (counted 
+in RTL instructions) for the RTL inliner with this parameter.
+The default value is 600.
+
 
 @item max-unrolled-insns
 The maximum number of instructions that a loop should have if that loop
index 576d8240c6568f9e4aba817b168460a7f2910b61..f26a94c66a1193f07ce65e00cf203ce5a9b0c590 100644 (file)
@@ -159,11 +159,13 @@ function_cannot_inline_p (fndecl)
   tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
 
   /* For functions marked as inline increase the maximum size to
-     MAX_INLINE_INSNS (-finline-limit-<n>).  For regular functions
-     use the limit given by INTEGRATE_THRESHOLD.  */
+     MAX_INLINE_INSNS_RTL (--param max-inline-insn-rtl=<n>). For
+     regular functions use the limit given by INTEGRATE_THRESHOLD.
+     Note that the RTL inliner is not used by the languages that use
+     the tree inliner (C, C++).  */
 
   int max_insns = (DECL_INLINE (fndecl))
-                  ? (MAX_INLINE_INSNS
+                  ? (MAX_INLINE_INSNS_RTL
                      + 8 * list_length (DECL_ARGUMENTS (fndecl)))
                   : INTEGRATE_THRESHOLD (fndecl);
 
index a0744f9b3ade63e1f5ad24fd4e88cf6c5b29f650..451c1a8d729a86f6cd7287be7572ab1777061e09 100644 (file)
@@ -50,10 +50,22 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    gets decreased.  */
 DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
          "max-inline-insns-single",
-         "The maximum number of instructions in a single function eliglible for inlining",
+         "The maximum number of instructions in a single function eligible for inlining",
          300)
 
-/* The repeated inlining limit. After this number of instructions 
+/* The single function inlining limit for functions that are
+   inlined by virtue of -finline-functions (-O3).
+   This limit should be chosen to be below or equal to the limit
+   that is applied to functions marked inlined (or defined in the
+   class declaration in C++) given by the "max-inline-insns-single"
+   parameter.
+   The default value is 300.  */
+DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
+         "max-inline-insns-auto",
+         "The maximum number of instructions when automatically inlining",
+         300)
+
+/* The repeated inlining limit.  After this number of instructions 
    (in the internal gcc representation, not real machine instructions)
    got inlined by repeated inlining, gcc starts to decrease the maximum
    number of inlinable instructions in the tree inliner.
@@ -62,16 +74,14 @@ DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
    could otherwise become very high.
    It is recommended to set this value to twice the value of the single
    function limit (set by the "max-inline-insns-single" parameter) or
-   higher. The default value is 600.
+   higher.  The default value is 600.
    Higher values mean that more inlining is done, resulting in
    better performance of the code, at the expense of higher 
    compile-time resource (time, memory) requirements and larger
-   binaries.  
-   This parameters also controls the maximum size of functions considered
-   for inlining in the RTL inliner.  */
+   binaries.  */
 DEFPARAM (PARAM_MAX_INLINE_INSNS,
          "max-inline-insns",
-         "The maximuem number of instructions by repeated inlining before gcc starts to throttle inlining",
+         "The maximum number of instructions by repeated inlining before gcc starts to throttle inlining",
          600)
 
 /* After the repeated inline limit has been exceeded (see
@@ -79,7 +89,7 @@ DEFPARAM (PARAM_MAX_INLINE_INSNS,
    decrease the size of single functions eligible for inlining.
    The slope of this linear function is given the negative
    reciprocal value (-1/x) of this parameter. 
-   The default vlue is 32.
+   The default value is 32.
    This linear function is used until it falls below a minimum
    value specified by the "min-inline-insns" parameter.  */
 DEFPARAM (PARAM_MAX_INLINE_SLOPE,
@@ -90,9 +100,9 @@ DEFPARAM (PARAM_MAX_INLINE_SLOPE,
 /* When gcc has inlined so many instructions (by repeated
    inlining) that the throttling limits the inlining very much,
    inlining for very small functions is still desirable to
-   achieve good runtime performance. The size of single functions 
+   achieve good runtime performance.  The size of single functions 
    (measured in gcc instructions) which will still be eligible for 
-   inlining then is given by this parameter. It defaults to 130.
+   inlining then is given by this parameter.  It defaults to 130.
    Only much later (after exceeding 128 times the recursive limit)
    inlining is cut down completely.  */
 DEFPARAM (PARAM_MIN_INLINE_INSNS,
@@ -100,6 +110,16 @@ DEFPARAM (PARAM_MIN_INLINE_INSNS,
          "The number of instructions in a single functions still eligible to inlining after a lot recursive inlining",
          130)
 
+/* For languages that (still) use the RTL inliner, we can specify
+   limits for the RTL inliner separately.
+   The parameter here defines the maximum number of RTL instructions
+   a function may have to be eligible for inlining in the RTL inliner.
+   The default value is 600.  */
+DEFPARAM (PARAM_MAX_INLINE_INSNS_RTL,
+         "max-inline-insns-rtl",
+         "The maximum number of instructions for the RTL inliner",
+         600)
+
 /* The maximum number of instructions to consider when looking for an
    instruction to fill a delay slot.  If more than this arbitrary
    number of instructions is searched, the time savings from filling
index 27021aa7c7ded49f5388fa6a02eafd1fa935550a..caddf853da5fe2ca1d971e61ef5495026e1d1150 100644 (file)
@@ -92,6 +92,10 @@ typedef enum compiler_param
   PARAM_VALUE (PARAM_MAX_INLINE_SLOPE)
 #define MIN_INLINE_INSNS \
   PARAM_VALUE (PARAM_MIN_INLINE_INSNS)
+#define MAX_INLINE_INSNS_AUTO \
+  PARAM_VALUE (PARAM_MAX_INLINE_INSNS_AUTO)
+#define MAX_INLINE_INSNS_RTL \
+  PARAM_VALUE (PARAM_MAX_INLINE_INSNS_RTL)
 #define MAX_DELAY_SLOT_INSN_SEARCH \
   PARAM_VALUE (PARAM_MAX_DELAY_SLOT_INSN_SEARCH)
 #define MAX_DELAY_SLOT_LIVE_SEARCH \
index 914ffcb3fcc73e7c311c6750485894ea73996e55..cd180719d6773bce565eedd20e0b9168ef688980 100644 (file)
@@ -330,7 +330,9 @@ print_node (file, prefix, node, indent)
       if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
        fputs (" suppress-debug", file);
 
-      if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node))
+      if (TREE_CODE (node) == FUNCTION_DECL && DID_INLINE_FUNC (node))
+       fputs (" autoinline", file);
+      else if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node))
        fputs (" inline", file);
       if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
        fputs (" built-in", file);
index 4135fff54a813f2c29c551f070b302456aeeb1f1..215b3186c525a6f9f970e3ce8340ac92651ed9f7 100644 (file)
@@ -2481,12 +2481,16 @@ rest_of_compilation (decl)
                  goto exit_rest_of_compilation;
                }
            }
-         else
-           /* ??? Note that this has the effect of making it look
-                like "inline" was specified for a function if we choose
-                to inline it.  This isn't quite right, but it's
-                probably not worth the trouble to fix.  */
+         else {
+           /* ??? Note that we used to just make it look like if
+                the "inline" keyword was specified when we decide
+                to inline it (because of -finline-functions).
+                garloff@suse.de, 2002-04-24: Add another flag to
+                actually record this piece of information.  */
+           if (!DECL_INLINE (decl))
+              DID_INLINE_FUNC (decl) = 1;
            inlinable = DECL_INLINE (decl) = 1;
+         }
        }
 
       insns = get_insns ();
@@ -4085,6 +4089,16 @@ decode_f_option (arg)
        read_integral_parameter (option_value, arg - 2,
                                 MAX_INLINE_INSNS);
       set_param_value ("max-inline-insns", val);
+      set_param_value ("max-inline-insns-single", val/2);
+      set_param_value ("max-inline-insns-auto", val/2);
+      set_param_value ("max-inline-insns-rtl", val);
+      if (val/4 < MIN_INLINE_INSNS)
+       {
+         if (val/4 > 10)
+           set_param_value ("min-inline-insns", val/4);
+         else
+           set_param_value ("min-inline-insns", 10);
+       }
     }
   else if ((option_value = skip_leading_substring (arg, "tls-model=")))
     {
index 71c4018d98f7455333412f764dbdbc4075f23249..5b5e77502f254336c10800a654c502cabefb6301 100644 (file)
@@ -935,6 +935,7 @@ inlinable_function_p (fn, id)
 {
   int inlinable;
   int currfn_insns;
+  int max_inline_insns_single = MAX_INLINE_INSNS_SINGLE;
 
   /* If we've already decided this function shouldn't be inlined,
      there's no need to check again.  */
@@ -943,7 +944,13 @@ inlinable_function_p (fn, id)
 
   /* Assume it is not inlinable.  */
   inlinable = 0;
-
+       
+  /* We may be here either because fn is declared inline or because
+     we use -finline-functions.  For the second case, we are more
+     restrictive.  */
+  if (DID_INLINE_FUNC (fn))
+    max_inline_insns_single = MAX_INLINE_INSNS_AUTO;
+       
   /* The number of instructions (estimated) of current function.  */
   currfn_insns = DECL_NUM_STMTS (fn) * INSNS_PER_STMT;
 
@@ -962,7 +969,7 @@ inlinable_function_p (fn, id)
      function to be of MAX_INLINE_INSNS_SINGLE size.  Make special
      allowance for extern inline functions, though.  */
   else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
-          && currfn_insns > MAX_INLINE_INSNS_SINGLE)
+          && currfn_insns > max_inline_insns_single)
     ;
   /* We can't inline functions that call __builtin_longjmp at all.
      The non-local goto machenery really requires the destination
index de9668b391851c3119b1a688285f96551c1eba81..4dd753a085111666da9c1d5bcd2a0f4d4b4be7ad 100644 (file)
@@ -1626,6 +1626,11 @@ struct tree_type GTY(())
    where it is called.  */
 #define DECL_INLINE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.inline_flag)
 
+/* Nonzero in a FUNCTION_DECL means this function has been found inlinable
+   only by virtue of -finline-functions  */
+#define DID_INLINE_FUNC(NODE) \
+  (FUNCTION_DECL_CHECK (NODE)->decl.inlined_function_flag)
+
 /* In a FUNCTION_DECL, nonzero if the function cannot be inlined.  */
 #define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable)
 
@@ -1811,7 +1816,8 @@ struct tree_decl GTY(())
   unsigned user_align : 1;
   unsigned uninlinable : 1;
   unsigned thread_local_flag : 1;
-  /* Two unused bits.  */
+  unsigned inlined_function_flag : 1;
+  /* One unused bit.  */
 
   unsigned lang_flag_0 : 1;
   unsigned lang_flag_1 : 1;