From 78a502caec5371cf5d107c3a6cf944bac0aaeb7c Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 14 Nov 2019 13:08:57 +0100 Subject: [PATCH] Add Optimization keyword for param_max_inline_insns_auto param. 2019-11-14 Martin Liska * ipa-cp.c (devirtualization_time_bonus): Use opt_for_fn of a callee to get value of the param. * ipa-inline.c (inline_insns_auto): Use proper opt_for_fn. * opts.c (maybe_default_option): Do not overwrite param value if optimization level does not match. Note that params usually have default value set via Init() keyword. * params.opt: Remove -param=max-inline-insns-auto-O2. * cif-code.def (MAX_INLINE_INSNS_AUTO_O2_LIMIT): Remove. * doc/invoke.texi: Remove documentation of max-inline-insns-auto-O2. 2019-11-14 Martin Liska * c-c++-common/asan/memcmp-1.c: Update expected backtrace. From-SVN: r278218 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/cif-code.def | 2 -- gcc/doc/invoke.texi | 11 +++-------- gcc/ipa-cp.c | 8 +++++--- gcc/ipa-inline.c | 18 ++++-------------- gcc/opts.c | 6 +++++- gcc/params.opt | 6 +----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/asan/memcmp-1.c | 4 ++-- 9 files changed, 38 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6b77d87a97d..7af5644024b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2019-11-14 Martin Liska + + * ipa-cp.c (devirtualization_time_bonus): Use opt_for_fn + of a callee to get value of the param. + * ipa-inline.c (inline_insns_auto): Use proper + opt_for_fn. + * opts.c (maybe_default_option): Do not overwrite param + value if optimization level does not match. Note that + params usually have default value set via Init() keyword. + * params.opt: Remove -param=max-inline-insns-auto-O2. + * cif-code.def (MAX_INLINE_INSNS_AUTO_O2_LIMIT): Remove. + * doc/invoke.texi: Remove documentation of + max-inline-insns-auto-O2. + 2019-11-14 Martin Liska * tree-switch-conversion.c (switch_conversion::switch_conversion): diff --git a/gcc/cif-code.def b/gcc/cif-code.def index a154f24f13d..b4403c96247 100644 --- a/gcc/cif-code.def +++ b/gcc/cif-code.def @@ -74,8 +74,6 @@ DEFCIFCODE(MAX_INLINE_INSNS_SINGLE_O2_LIMIT, CIF_FINAL_NORMAL, N_("--param max-inline-insns-single-O2 limit reached")) DEFCIFCODE(MAX_INLINE_INSNS_AUTO_LIMIT, CIF_FINAL_NORMAL, N_("--param max-inline-insns-auto limit reached")) -DEFCIFCODE(MAX_INLINE_INSNS_AUTO_O2_LIMIT, CIF_FINAL_NORMAL, - N_("--param max-inline-insns-auto-O2 limit reached")) DEFCIFCODE(INLINE_UNIT_GROWTH_LIMIT, CIF_FINAL_NORMAL, N_("--param inline-unit-growth limit reached")) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 69f057e7a12..fe79ca2247a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11283,16 +11283,11 @@ applied. In other cases @option{max-inline-insns-single-O2} is applied. @item max-inline-insns-auto -@item max-inline-insns-auto-O2 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 are investigated. To those functions, a different (more restrictive) limit compared to functions declared inline can -be applied. - -For functions compiled with optimization levels -@option{-O3} and @option{-Ofast} parameter @option{max-inline-insns-auto} is -applied. In other cases @option{max-inline-insns-auto-O2} is applied. +be applied (@option{--param max-inline-insns-auto}). @item max-inline-insns-small This is bound applied to calls which are considered relevant with @@ -11313,8 +11308,8 @@ execute function prologue and epilogue @item inline-heuristics-hint-percent @item inline-heuristics-hint-percent-O2 The scale (in percents) applied to @option{inline-insns-single}, -@option{inline-insns-single-O2}, @option{inline-insns-auto}, -@option{inline-insns-auto-O2} when inline heuristics hints that inlining is +@option{inline-insns-single-O2}, @option{inline-insns-auto} +when inline heuristics hints that inlining is very profitable (will enable later optimizations). For functions compiled with optimization levels diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index f0d354b3704..86c625355b6 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2936,11 +2936,13 @@ devirtualization_time_bonus (struct cgraph_node *node, int size = ipa_size_summaries->get (callee)->size; /* FIXME: The values below need re-considering and perhaps also integrating into the cost metrics, at lest in some very basic way. */ - if (size <= param_max_inline_insns_auto / 4) + int max_inline_insns_auto + = opt_for_fn (callee->decl, param_max_inline_insns_auto); + if (size <= max_inline_insns_auto / 4) res += 31 / ((int)speculative + 1); - else if (size <= param_max_inline_insns_auto / 2) + else if (size <= max_inline_insns_auto / 2) res += 15 / ((int)speculative + 1); - else if (size <= param_max_inline_insns_auto + else if (size <= max_inline_insns_auto || DECL_DECLARED_INLINE_P (callee->decl)) res += 7 / ((int)speculative + 1); } diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 78ec0ec685f..effb59784a3 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -417,20 +417,10 @@ inline_insns_single (cgraph_node *n, bool hint) static int inline_insns_auto (cgraph_node *n, bool hint) { - if (opt_for_fn (n->decl, optimize) >= 3) - { - if (hint) - return param_max_inline_insns_auto - * param_inline_heuristics_hint_percent / 100; - return param_max_inline_insns_auto; - } - else - { - if (hint) - return param_max_inline_insns_auto_o2 - * param_inline_heuristics_hint_percent_o2 / 100; - return param_max_inline_insns_auto_o2; - } + int max_inline_insns_auto = opt_for_fn (n->decl, param_max_inline_insns_auto); + if (hint) + return max_inline_insns_auto * param_inline_heuristics_hint_percent / 100; + return max_inline_insns_auto; } /* Decide if we can inline the edge and possibly update diff --git a/gcc/opts.c b/gcc/opts.c index 74f05f1b58d..addebf15365 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -388,7 +388,8 @@ maybe_default_option (struct gcc_options *opts, lang_mask, DK_UNSPECIFIED, loc, handlers, true, dc); else if (default_opt->arg == NULL - && !option->cl_reject_negative) + && !option->cl_reject_negative + && !(option->flags & CL_PARAMS)) handle_generated_option (opts, opts_set, default_opt->opt_index, default_opt->arg, !default_opt->value, lang_mask, DK_UNSPECIFIED, loc, @@ -541,6 +542,9 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_3_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_DYNAMIC }, { OPT_LEVELS_3_PLUS, OPT_fversion_loops_for_strides, NULL, 1 }, + /* -O3 parameters. */ + { OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_auto_, NULL, 30 }, + /* -Ofast adds optimizations to -O3. */ { OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 }, { OPT_LEVELS_FAST, OPT_fallow_store_data_races, NULL, 1 }, diff --git a/gcc/params.opt b/gcc/params.opt index be0a3a15598..d8a10b8be4a 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -467,11 +467,7 @@ Common Joined UInteger Var(param_max_hoist_depth) Init(30) Param Maximum depth of search in the dominator tree for expressions to hoist. -param=max-inline-insns-auto= -Common Joined UInteger Var(param_max_inline_insns_auto) Init(30) Param -The maximum number of instructions when automatically inlining with -O3 and -Ofast. - --param=max-inline-insns-auto-O2= -Common Joined UInteger Var(param_max_inline_insns_auto_o2) Init(15) Param +Common Joined UInteger Var(param_max_inline_insns_auto) Init(15) Optimization Param The maximum number of instructions when automatically inlining. -param=max-inline-insns-recursive= diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19aaa423bfc..914f00593ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-14 Martin Liska + + * c-c++-common/asan/memcmp-1.c: Update expected backtrace. + 2019-11-14 Jakub Jelinek * c-c++-common/gomp/declare-variant-11.c: Add "sse4.2" and "sse4.1" diff --git a/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc/testsuite/c-c++-common/asan/memcmp-1.c index 0a513c05ee1..0403ad78945 100644 --- a/gcc/testsuite/c-c++-common/asan/memcmp-1.c +++ b/gcc/testsuite/c-c++-common/asan/memcmp-1.c @@ -16,5 +16,5 @@ main () } /* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow.*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #2 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #\[1-9\] 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #\[2-9\] 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -- 2.30.2