diff mbox series

Add Optimization keyword for param_max_inline_insns_auto param.

Message ID 8b822a10-2c4f-1ff0-1898-2285ac5d01c9@suse.cz
State New
Headers show
Series Add Optimization keyword for param_max_inline_insns_auto param. | expand

Commit Message

Martin Liška Nov. 14, 2019, noon UTC
On 11/13/19 2:36 PM, Richard Biener wrote:
> Hmm, can you please - as exercise - add Optimization only for
> the "formerly" _o2 params you remove in the other patch to see
> if with this you indeed get at a NOP effect?

Sure, there's a patch that removed max-inline-insns-auto-O2.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
I see the same backtrace change in libsanitizer as in the original
patch series.

Ready to be installed?
Thanks,
Martin

Comments

Richard Biener Nov. 14, 2019, 12:04 p.m. UTC | #1
On Thu, Nov 14, 2019 at 1:00 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 11/13/19 2:36 PM, Richard Biener wrote:
> > Hmm, can you please - as exercise - add Optimization only for
> > the "formerly" _o2 params you remove in the other patch to see
> > if with this you indeed get at a NOP effect?
>
> Sure, there's a patch that removed max-inline-insns-auto-O2.
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> I see the same backtrace change in libsanitizer as in the original
> patch series.
>
> Ready to be installed?

OK.

Richard.

> Thanks,
> Martin
diff mbox series

Patch

From 7a46cb4d5629e556cb2a17af6b83069dddddfc90 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 14 Nov 2019 10:56:57 +0100
Subject: [PATCH] Add Optimization keyword for param_max_inline_insns_auto
 param.

gcc/ChangeLog:

2019-11-14  Martin Liska  <mliska@suse.cz>

	* 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.

gcc/testsuite/ChangeLog:

2019-11-14  Martin Liska  <mliska@suse.cz>

	* c-c++-common/asan/memcmp-1.c: Update expected backtrace.
---
 gcc/cif-code.def                           |  2 --
 gcc/doc/invoke.texi                        |  7 +------
 gcc/ipa-cp.c                               |  8 +++++---
 gcc/ipa-inline.c                           | 18 ++++--------------
 gcc/opts.c                                 |  6 +++++-
 gcc/params.opt                             |  6 +-----
 gcc/testsuite/c-c++-common/asan/memcmp-1.c |  4 ++--
 7 files changed, 18 insertions(+), 33 deletions(-)

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..e5cb0a3242b 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
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/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.24.0