OSDN Git Service

* flags.h (inline_max_insns): Declare.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Apr 1999 23:35:15 +0000 (23:35 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Apr 1999 23:35:15 +0000 (23:35 +0000)
        * integrate.c (inline_max_insns): New variable.
        (function_cannot_inline_p): Use it.
        * toplev.c (main): Add the flag -finline-limit-n.
        (display_help): Document -finline-limit-n.
        * invoke.texi: Document -finline-limit-n

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26629 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/flags.h
gcc/integrate.c
gcc/invoke.texi
gcc/toplev.c

index 8a4eb26..2f05463 100644 (file)
@@ -1,3 +1,12 @@
+Mon Apr 26 00:28:25 1999  Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
+
+       * flags.h (inline_max_insns): Declare.
+       * integrate.c (inline_max_insns): New variable.
+       (function_cannot_inline_p): Use it.
+       * toplev.c (main): Add the flag -finline-limit-n.
+       (display_help): Document -finline-limit-n.
+       * invoke.texi: Document -finline-limit-n
+
 Sun Apr 25 23:03:32 1999  Richard Henderson  <rth@cygnus.com>
 
        * stmt.c (expand_asm_operands): Reload in-out reg-only memory operands.
index e73c3fd..2c0ed40 100644 (file)
@@ -507,6 +507,10 @@ extern int current_function_is_thunk;
 extern int g_switch_value;
 extern int g_switch_set;
 
+/* Value of the -finline-limit flag.  */
+
+extern int inline_max_insns;
+
 /* Nonzero if we dump in VCG format, not plain text.  */
 extern int dump_for_graph;
 
index 76f7144..33a96c4 100644 (file)
@@ -86,6 +86,16 @@ static void process_reg_param                PROTO((struct inline_remap *, rtx,
 
 void set_decl_abstract_flags           PROTO((tree, int));
 static tree copy_and_set_decl_abstract_origin PROTO((tree));
+
+/* The maximum number of instructions accepted for inlining a
+   function.  Increasing values mean more agressive inlining.
+   This affects currently only functions explicitly marked as
+   inline (or methods defined within the class definition for C++).
+   The default value of 10000 is arbitrary but high to match the
+   previously unlimited gcc capabilities.  */
+
+int inline_max_insns = 10000;
+
 \f
 /* Returns the Ith entry in the label_map contained in MAP.  If the
    Ith entry has not yet been set, return a fresh label.  This function
@@ -116,7 +126,16 @@ function_cannot_inline_p (fndecl)
 {
   register rtx insn;
   tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
-  int max_insns = INTEGRATE_THRESHOLD (fndecl);
+
+  /* For functions marked as inline increase the maximum size to
+     inline_max_insns (-finline-limit-<n>).  For regular functions
+     use the limit given by INTEGRATE_THRESHOLD.  */
+
+  int max_insns = (DECL_INLINE (fndecl))
+                  ? (inline_max_insns
+                     + 8 * list_length (DECL_ARGUMENTS (fndecl)))
+                  : INTEGRATE_THRESHOLD (fndecl);
+
   register int ninsns = 0;
   register tree parms;
   rtx result;
@@ -136,7 +155,7 @@ function_cannot_inline_p (fndecl)
     return current_function_cannot_inline;
 
   /* If its not even close, don't even look.  */
-  if (!DECL_INLINE (fndecl) && get_max_uid () > 3 * max_insns)
+  if (get_max_uid () > 3 * max_insns)
     return N_("function too large to be inline");
 
 #if 0
@@ -170,7 +189,7 @@ function_cannot_inline_p (fndecl)
        return N_("function with transparent unit parameter cannot be inline");
     }
 
-  if (!DECL_INLINE (fndecl) && get_max_uid () > max_insns)
+  if (get_max_uid () > max_insns)
     {
       for (ninsns = 0, insn = get_first_nonparm_insn ();
           insn && ninsns < max_insns;
index 5cf365a..1ca77e5 100644 (file)
@@ -154,7 +154,7 @@ in the following sections.
 -fdelayed-branch   -fexpensive-optimizations
 -ffast-math  -ffloat-store  -fforce-addr  -fforce-mem
 -fdata-sections -ffunction-sections  -fgcse 
--finline-functions -fkeep-inline-functions
+-finline-functions -finline-limit-@var{n} -fkeep-inline-functions
 -fno-default-inline -fno-defer-pop  -fno-function-cse
 -fno-inline  -fno-peephole  -fomit-frame-pointer -fregmove
 -frerun-cse-after-loop  -frerun-loop-opt -fschedule-insns
@@ -2302,6 +2302,23 @@ If all calls to a given function are integrated, and the function is
 declared @code{static}, then the function is normally not output as
 assembler code in its own right.
 
+@item -finline-limit-@var{n}
+By default, gcc limits the size of functions that can be inlined.  This flag
+allows the control of this limit for functions that are explicitly marked as
+inline (ie marked with the inline keyword or defined within the class 
+definition in c++).  @var{n} is the size of functions that can be inlined in 
+number of pseudo instructions (not counting parameter handling).  The default
+value of n is 10000.  Increasing this value can result in more inlined code at
+the cost of compilation time and memory consumption.  Decreasing usually makes
+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++.
+
+@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
+release to an another.
+
 @item -fkeep-inline-functions
 Even if all calls to a given function are integrated, and the function
 is declared @code{static}, nevertheless output a separate run-time
index f0e84f4..f5e534c 100644 (file)
@@ -4488,6 +4488,7 @@ display_help ()
   printf ("  -ffixed-<register>      Mark <register> as being unavailable to the compiler\n");
   printf ("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n");
   printf ("  -fcall-saved-<register> Mark <register> as being preserved across functions\n");
+  printf ("  -finline-limit-<number> Limits the size of inlined functions to <number>\n");
 
   for (i = NUM_ELEM (f_options); i--;)
     {
@@ -5062,6 +5063,9 @@ main (argc, argv)
 
              if (found)
                ;
+             else if (!strncmp (p, "inline-limit-", 13))
+               inline_max_insns =
+                 read_integral_parameter (p + 13, p - 2, inline_max_insns);
 #ifdef HAIFA
 #ifdef INSN_SCHEDULING
              else if (!strncmp (p, "sched-verbose-",14))