public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282]
@ 2022-04-19 19:28 Sergei Trofimovich
  2022-04-19 19:32 ` Martin Liška
  0 siblings, 1 reply; 2+ messages in thread
From: Sergei Trofimovich @ 2022-04-19 19:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, Martin Liska, Nathan Sidwell, Sergei Trofimovich

From: Sergei Trofimovich <siarheit@google.com>

TOPN metrics are histograms that contain overall count and per-bucket
count. Overall count can be negative when two profiles merge and some
of per-bucket metrics are disacarded.

Noticed as an ICE on python PGO build where gcc crashes as:

    during IPA pass: modref
    a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340
       36 | }
          | ^
    stream_out_histogram_value(output_block*, histogram_value_t*)
            gcc/value-prof.cc:340

gcc/ChangeLog:

	PR gcov-profile/105282
	* value-prof.cc (stream_out_histogram_value): Allow negative counts
	on HIST_TYPE_INDIR_CALL.

(cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3)
---
 gcc/value-prof.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 42748771192..688089b04d2 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -336,6 +336,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
 	/* Note that the IOR counter tracks pointer values and these can have
 	   sign bit set.  */
 	;
+      else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0)
+	/* 'all' counter overflow is stored as a negative value. Individual
+	   counters and values are expected to be non-negative.  */
+	;
       else
 	gcc_assert (value >= 0);
 
-- 
2.35.1


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

* Re: [PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282]
  2022-04-19 19:28 [PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282] Sergei Trofimovich
@ 2022-04-19 19:32 ` Martin Liška
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liška @ 2022-04-19 19:32 UTC (permalink / raw)
  To: Sergei Trofimovich, gcc-patches
  Cc: Jan Hubicka, Nathan Sidwell, Sergei Trofimovich, Jakub Jelinek,
	Richard Biener

On 4/19/22 21:28, Sergei Trofimovich wrote:
> From: Sergei Trofimovich <siarheit@google.com>
> 
> TOPN metrics are histograms that contain overall count and per-bucket
> count. Overall count can be negative when two profiles merge and some
> of per-bucket metrics are disacarded.

I'm fine with that but I think, as we're close to 11.3.0, it's up to release managers
who should approve that.

Cheers,
Martin

> 
> Noticed as an ICE on python PGO build where gcc crashes as:
> 
>      during IPA pass: modref
>      a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340
>         36 | }
>            | ^
>      stream_out_histogram_value(output_block*, histogram_value_t*)
>              gcc/value-prof.cc:340
> 
> gcc/ChangeLog:
> 
> 	PR gcov-profile/105282
> 	* value-prof.cc (stream_out_histogram_value): Allow negative counts
> 	on HIST_TYPE_INDIR_CALL.
> 
> (cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3)
> ---
>   gcc/value-prof.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
> index 42748771192..688089b04d2 100644
> --- a/gcc/value-prof.c
> +++ b/gcc/value-prof.c
> @@ -336,6 +336,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
>   	/* Note that the IOR counter tracks pointer values and these can have
>   	   sign bit set.  */
>   	;
> +      else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0)
> +	/* 'all' counter overflow is stored as a negative value. Individual
> +	   counters and values are expected to be non-negative.  */
> +	;
>         else
>   	gcc_assert (value >= 0);
>   


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

end of thread, other threads:[~2022-04-19 19:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 19:28 [PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282] Sergei Trofimovich
2022-04-19 19:32 ` Martin Liška

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