Remove wrong assert about single value profiler.

Message ID 77dbc19c-5fa9-5179-8fc5-40a83593d3ca@suse.cz
State New
Headers show
Series
  • Remove wrong assert about single value profiler.
Related show

Commit Message

Martin Liška June 11, 2019, 1:17 p.m.
Hi.

The assert in stream_out_histogram_value is wrong about single value
counters where we can have a negative number as a target of an indirect
call. And likewise we use special value -1 for counters that overflow.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

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

	* value-prof.c (stream_out_histogram_value): Only first value
	can't be negative.
---
 gcc/value-prof.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Hubicka June 11, 2019, 1:30 p.m. | #1
> Hi.

> 

> The assert in stream_out_histogram_value is wrong about single value

> counters where we can have a negative number as a target of an indirect

> call. And likewise we use special value -1 for counters that overflow.

> 

> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

> 

> Ready to be installed?

OK,
Thanks!
Honza
> Thanks,

> Martin

> 

> gcc/ChangeLog:

> 

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

> 

> 	* value-prof.c (stream_out_histogram_value): Only first value

> 	can't be negative.

> ---

>  gcc/value-prof.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> 


> diff --git a/gcc/value-prof.c b/gcc/value-prof.c

> index 57ef9e441fb..7289a698b71 100644

> --- a/gcc/value-prof.c

> +++ b/gcc/value-prof.c

> @@ -331,7 +331,7 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)

>        /* When user uses an unsigned type with a big value, constant converted

>  	 to gcov_type (a signed type) can be negative.  */

>        gcov_type value = hist->hvalue.counters[i];

> -      if (hist->type == HIST_TYPE_SINGLE_VALUE && (i > 0 && ((i - 1) % 2) == 0))

> +      if (hist->type == HIST_TYPE_SINGLE_VALUE && i > 0)

>  	;

>        else

>  	gcc_assert (value >= 0);

>

Patch

diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 57ef9e441fb..7289a698b71 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -331,7 +331,7 @@  stream_out_histogram_value (struct output_block *ob, histogram_value hist)
       /* When user uses an unsigned type with a big value, constant converted
 	 to gcov_type (a signed type) can be negative.  */
       gcov_type value = hist->hvalue.counters[i];
-      if (hist->type == HIST_TYPE_SINGLE_VALUE && (i > 0 && ((i - 1) % 2) == 0))
+      if (hist->type == HIST_TYPE_SINGLE_VALUE && i > 0)
 	;
       else
 	gcc_assert (value >= 0);