public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] More precise message with -Winline
@ 2019-07-24  9:57 Eric Botcazou
  2019-07-24 13:38 ` Richard Biener
  2019-07-25 18:23 ` Andi Kleen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Botcazou @ 2019-07-24  9:57 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi,

for EH cleanups, the branch probability heuristics can consider that edges are 
never taken, i.e. their profile count is set to zero.  In this case, no matter 
how you tweak the inlining parameters, you cannot get function calls inlined, 
but -Winline nevertheless prints the standard message about unlikely calls as 
in the cases when tweaking the inlining parameters can work.

Therefore the attached patch adds a new CIF code with the warning message:

"call is never executed and code size would grow [-Winline]"

for this case, thus signaling the user that he'd better not waste time trying 
to get the call inlined.

Tested on x86_64-suse-linux, OK for the mainline?


2019-07-24  Eric Botcazou  <ebotcazou@adacore.com>

	* cif-code.def (NEVER_CALL): New code.
	* ipa-inline.c (want_inline_small_function_p): Fix formatting issues.
	Set the failure to CIF_NEVER_CALL if the IPA count is zero.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2815 bytes --]

Index: cif-code.def
===================================================================
--- cif-code.def	(revision 273480)
+++ cif-code.def	(working copy)
@@ -83,6 +83,10 @@ DEFCIFCODE(RECURSIVE_INLINING, CIF_FINAL_NORMAL,
 DEFCIFCODE(UNLIKELY_CALL, CIF_FINAL_NORMAL,
 	   N_("call is unlikely and code size would grow"))
 
+/* Call is considered never executed.  */
+DEFCIFCODE(NEVER_CALL, CIF_FINAL_NORMAL,
+	   N_("call is never executed and code size would grow"))
+
 /* Function is not declared as inline.  */
 DEFCIFCODE(NOT_DECLARED_INLINED, CIF_FINAL_NORMAL,
 	   N_("function not declared inline and code size would grow"))
Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 273480)
+++ ipa-inline.c	(working copy)
@@ -810,7 +810,7 @@ want_inline_small_function_p (struct cgraph_edge *
 				  | INLINE_HINT_loop_stride))
 		       && !(big_speedup = big_speedup_p (e)))))
 	{
-          e->inline_failed = CIF_MAX_INLINE_INSNS_SINGLE_LIMIT;
+	  e->inline_failed = CIF_MAX_INLINE_INSNS_SINGLE_LIMIT;
 	  want_inline = false;
 	}
       else if (!DECL_DECLARED_INLINE_P (callee->decl)
@@ -818,12 +818,12 @@ want_inline_small_function_p (struct cgraph_edge *
 	       && growth >= PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SMALL))
 	{
 	  /* growth_likely_positive is expensive, always test it last.  */
-          if (growth >= MAX_INLINE_INSNS_SINGLE
+	  if (growth >= MAX_INLINE_INSNS_SINGLE
 	      || growth_likely_positive (callee, growth))
 	    {
-              e->inline_failed = CIF_NOT_DECLARED_INLINED;
+	      e->inline_failed = CIF_NOT_DECLARED_INLINED;
 	      want_inline = false;
- 	    }
+	    }
 	}
       /* Apply MAX_INLINE_INSNS_AUTO limit for functions not declared inline
 	 Upgrade it to MAX_INLINE_INSNS_SINGLE when hints suggests that
@@ -839,12 +839,12 @@ want_inline_small_function_p (struct cgraph_edge *
 	       && !(big_speedup == -1 ? big_speedup_p (e) : big_speedup))
 	{
 	  /* growth_likely_positive is expensive, always test it last.  */
-          if (growth >= MAX_INLINE_INSNS_SINGLE
+	  if (growth >= MAX_INLINE_INSNS_SINGLE
 	      || growth_likely_positive (callee, growth))
 	    {
 	      e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
 	      want_inline = false;
- 	    }
+	    }
 	}
       /* If call is cold, do not inline when function body would grow. */
       else if (!e->maybe_hot_p ()
@@ -851,7 +851,10 @@ want_inline_small_function_p (struct cgraph_edge *
 	       && (growth >= MAX_INLINE_INSNS_SINGLE
 		   || growth_likely_positive (callee, growth)))
 	{
-          e->inline_failed = CIF_UNLIKELY_CALL;
+	  if (e->count.ipa () == profile_count::zero ())
+	    e->inline_failed = CIF_NEVER_CALL;
+	  else
+	    e->inline_failed = CIF_UNLIKELY_CALL;
 	  want_inline = false;
 	}
     }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] More precise message with -Winline
  2019-07-24  9:57 [patch] More precise message with -Winline Eric Botcazou
@ 2019-07-24 13:38 ` Richard Biener
  2019-07-24 14:39   ` Eric Botcazou
  2019-07-25 18:23 ` Andi Kleen
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Biener @ 2019-07-24 13:38 UTC (permalink / raw)
  To: Eric Botcazou, Jan Hubicka; +Cc: GCC Patches

On Wed, Jul 24, 2019 at 11:29 AM Eric Botcazou <ebotcazou@adacore.com> wrote:
>
> Hi,
>
> for EH cleanups, the branch probability heuristics can consider that edges are
> never taken, i.e. their profile count is set to zero.  In this case, no matter
> how you tweak the inlining parameters, you cannot get function calls inlined,
> but -Winline nevertheless prints the standard message about unlikely calls as
> in the cases when tweaking the inlining parameters can work.
>
> Therefore the attached patch adds a new CIF code with the warning message:
>
> "call is never executed and code size would grow [-Winline]"
>
> for this case, thus signaling the user that he'd better not waste time trying
> to get the call inlined.
>
> Tested on x86_64-suse-linux, OK for the mainline?

Looks good besides

+         if (e->count.ipa () == profile_count::zero ())
+           e->inline_failed = CIF_NEVER_CALL;

does it actually matter what kind of profile quality e->count.ipa has
compared to profile_count::zero ()?  Also

+/* Call is considered never executed.  */
+DEFCIFCODE(NEVER_CALL, CIF_FINAL_NORMAL,
+          N_("call is never executed and code size would grow"))

suggests the call is never executed, but we only assume that
(or the profile training run never hit it).

Richard.

>
>
> 2019-07-24  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * cif-code.def (NEVER_CALL): New code.
>         * ipa-inline.c (want_inline_small_function_p): Fix formatting issues.
>         Set the failure to CIF_NEVER_CALL if the IPA count is zero.
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] More precise message with -Winline
  2019-07-24 13:38 ` Richard Biener
@ 2019-07-24 14:39   ` Eric Botcazou
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Botcazou @ 2019-07-24 14:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jan Hubicka, GCC Patches

> Looks good besides
> 
> +         if (e->count.ipa () == profile_count::zero ())
> +           e->inline_failed = CIF_NEVER_CALL;
> 
> does it actually matter what kind of profile quality e->count.ipa has
> compared to profile_count::zero ()?

I don't really know, the other examples in the function use e->count.ipa too.

> Also
> 
> +/* Call is considered never executed.  */
> +DEFCIFCODE(NEVER_CALL, CIF_FINAL_NORMAL,
> +          N_("call is never executed and code size would grow"))
> 
> suggests the call is never executed, but we only assume that
> (or the profile training run never hit it).

OK, I added "considered" as in the comment above.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] More precise message with -Winline
  2019-07-24  9:57 [patch] More precise message with -Winline Eric Botcazou
  2019-07-24 13:38 ` Richard Biener
@ 2019-07-25 18:23 ` Andi Kleen
  2019-07-25 19:24   ` Eric Botcazou
  1 sibling, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2019-07-25 18:23 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

Eric Botcazou <ebotcazou@adacore.com> writes:

> Hi,
>
> for EH cleanups, the branch probability heuristics can consider that edges are 
> never taken, i.e. their profile count is set to zero.  In this case, no matter 
> how you tweak the inlining parameters, you cannot get function calls inlined, 
> but -Winline nevertheless prints the standard message about unlikely calls as 
> in the cases when tweaking the inlining parameters can work.
>
> Therefore the attached patch adds a new CIF code with the warning message:
>
> "call is never executed and code size would grow [-Winline]"

That seems misleading, unless the exception is really never thrown.

Maybe s/never/rarely/


-Andi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] More precise message with -Winline
  2019-07-25 18:23 ` Andi Kleen
@ 2019-07-25 19:24   ` Eric Botcazou
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Botcazou @ 2019-07-25 19:24 UTC (permalink / raw)
  To: Andi Kleen; +Cc: gcc-patches

> That seems misleading, unless the exception is really never thrown.

See my earlier answer to Richard.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-25 19:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24  9:57 [patch] More precise message with -Winline Eric Botcazou
2019-07-24 13:38 ` Richard Biener
2019-07-24 14:39   ` Eric Botcazou
2019-07-25 18:23 ` Andi Kleen
2019-07-25 19:24   ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).