public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] squash spurious warnings in dominance.c
Date: Tue, 25 Apr 2017 10:03:00 -0000	[thread overview]
Message-ID: <CAFiYyc3_oswu9iM8MSseOeFTts7yGOk5CeZRTrMxaXF1zeB+Ow@mail.gmail.com> (raw)
In-Reply-To: <eb812563-055b-1054-66b0-ca51963a559f@gmail.com>

On Mon, Apr 24, 2017 at 11:07 PM, Martin Sebor <msebor@gmail.com> wrote:
> On 04/24/2017 01:32 AM, Richard Biener wrote:
>>
>> On Sat, Apr 22, 2017 at 2:51 AM, Martin Sebor <msebor@gmail.com> wrote:
>>>
>>> Bug 80486 - spurious -Walloc-size-larger-than and
>>> -Wstringop-overflow in dominance.c during profiledbootstrap
>>> points out a number of warnings that show up in dominance.c
>>> during a profiledbootstrap.  I'm pretty sure the warnings
>>> are due to the size check the C++ new expression introduces
>>> to avoid unsigned overflow before calling operator new, and
>>> by some optimization like jump threading introducing a branch
>>> with the call to the allocation function and memset with
>>> the excessive constant size.
>>>
>>> Two ways to avoid it come to mind: 1) use the libiberty
>>> XCNEWVEC and XNEWVEC macros instead of C++ new expressions,
>>> and 2) constraining the size variable to a valid range.
>>>
>>> Either of these approaches should result in better code than
>>> the new expression because they both eliminate the test for
>>> the overflow.  Attached is a patch that implements (1). I
>>> chose it mainly because it seems in line with GCC's memory
>>> management policy and with avoiding exceptions.
>>>
>>> An alternate patch should be straightforward.  Either add
>>> an assert like the one below or change the type of
>>> m_n_basic_blocks from size_t to unsigned.  This approach,
>>> though less intrusive, will likely bring the warning back
>>> in ILP32 builds; I'm not sure if it matters.
>>
>>
>> Please change m_n_basic_blocks (and local copies) from size_t
>> to unsigned int.  This is an odd inconsistency that's worth fixing
>> in any case.
>
>
> Attached is this version of the patch.  It also eliminates
> the warnings and passes profiledbootstrap/regression test
> on x86_64.

Ok.

Thanks,
Richard.

> Martin
>

      reply	other threads:[~2017-04-25  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-22 13:49 Martin Sebor
2017-04-24  7:41 ` Richard Biener
2017-04-24 21:20   ` Martin Sebor
2017-04-25 10:03     ` Richard Biener [this message]

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=CAFiYyc3_oswu9iM8MSseOeFTts7yGOk5CeZRTrMxaXF1zeB+Ow@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    /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).