From f9e814f10036123463e12b12065d9576f80f6e23 Mon Sep 17 00:00:00 2001 From: Theodore Papadopoulo Date: Mon, 26 Apr 1999 01:35:15 +0200 Subject: [PATCH] flags.h (inline_max_insns): Declare. * 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 From-SVN: r26629 --- gcc/ChangeLog | 9 +++++++++ gcc/flags.h | 4 ++++ gcc/integrate.c | 25 ++++++++++++++++++++++--- gcc/invoke.texi | 19 ++++++++++++++++++- gcc/toplev.c | 4 ++++ 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a4eb262c68..2f0546391e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Mon Apr 26 00:28:25 1999 Theodore Papadopoulo + + * 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 * stmt.c (expand_asm_operands): Reload in-out reg-only memory operands. diff --git a/gcc/flags.h b/gcc/flags.h index e73c3fdbfc7..2c0ed409ec2 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -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; diff --git a/gcc/integrate.c b/gcc/integrate.c index 76f71441e55..33a96c40f91 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -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; + /* 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-). 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; diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 5cf365ab42b..1ca77e54334 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -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 diff --git a/gcc/toplev.c b/gcc/toplev.c index f0e84f42e3a..f5e534cb2fc 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -4488,6 +4488,7 @@ display_help () printf (" -ffixed- Mark as being unavailable to the compiler\n"); printf (" -fcall-used- Mark as being corrupted by function calls\n"); printf (" -fcall-saved- Mark as being preserved across functions\n"); + printf (" -finline-limit- Limits the size of inlined functions to \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)) -- 2.30.2