public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: "Jan Hubicka" <hubicka@ucw.cz>, "Martin Liška" <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix UBSAN errors in ipa-cp.
Date: Wed, 23 Sep 2020 16:32:21 +0200	[thread overview]
Message-ID: <ri6zh5gr2bu.fsf@suse.cz> (raw)
In-Reply-To: <20200923135712.GC96998@kam.mff.cuni.cz>

Hi,

On Wed, Sep 23 2020, Jan Hubicka wrote:
>> There's patch that does that.
>> 
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>> 
>> Ready to be installed?
>> Thanks,
>> Martin
>
>> From ff5f78110684ed9aedde15d19e856b3acf649971 Mon Sep 17 00:00:00 2001
>> From: Martin Liska <mliska@suse.cz>
>> Date: Wed, 23 Sep 2020 15:10:43 +0200
>> Subject: [PATCH] Port IPA CP time and size to sreal
>> 
>> gcc/ChangeLog:
>> 
>> 	* ipa-cp.c (ipcp_lattice::print): Print sreal values
>> 	with to_double.
>> 	(incorporate_penalties): Change type to sreal.
>> 	(good_cloning_opportunity_p): Change args to sreal.
>> 	(get_max_overall_size): Work in sreal type.
>> 	(estimate_local_effects): Likewise.
>> 	(safe_add): Remove.
>> 	(value_topo_info::propagate_effects): Work in sreal type.
>> 	(ipcp_propagate_stage): Print sreal numbers.
>> 	(decide_about_value): Work in sreal type.
>> ---
>>  gcc/ipa-cp.c | 128 ++++++++++++++++++++++++---------------------------
>>  1 file changed, 59 insertions(+), 69 deletions(-)
>> 
>> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
>> index b3e7d41ea10..9a79b5862f8 100644
>> --- a/gcc/ipa-cp.c
>> +++ b/gcc/ipa-cp.c
>> @@ -157,10 +157,10 @@ class ipcp_value_base
>>  public:
>>    /* Time benefit and size cost that specializing the function for this value
>>       would bring about in this function alone.  */
>> -  int local_time_benefit, local_size_cost;
>> +  sreal local_time_benefit, local_size_cost;
>>    /* Time benefit and size cost that specializing the function for this value
>>       can bring about in it's callees (transitively).  */
>> -  int prop_time_benefit, prop_size_cost;
>> +  sreal prop_time_benefit, prop_size_cost;
>
> Time calculaitons can get out of hand, while size calculations still
> corresponds to actual program instructions, so int should be enough
> (I would start using 64bit ints for whole program statistics, like
> overall size below because eventaully we may hit that).

Please note that in PR 96806 we have seen size overflow int when the
value of param ipa-cp-max-recursive-depth is huge.  So you either need
to keep using safe_add for it or make it a 64 bit int everywhere (and
hope that other things break earlier if someone wants to use a value of
the param big enough to overflow even 64 bits - or that people testing
GCC with strange parameters do not test values this extreme :-).

Martin


  reply	other threads:[~2020-09-23 14:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 12:19 Martin Liška
2020-09-23 12:32 ` Jan Hubicka
2020-09-23 12:39   ` Martin Liška
2020-09-23 13:50     ` Martin Liška
2020-09-23 13:57       ` Jan Hubicka
2020-09-23 14:32         ` Martin Jambor [this message]
2020-09-23 15:02       ` Martin Jambor
2020-09-24  7:20         ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ri6zh5gr2bu.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).