public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PR middle-end/82123] 00/06 Use EVRP range data in sprintf warnings
Date: Wed, 21 Feb 2018 02:38:00 -0000	[thread overview]
Message-ID: <f218eb8d-d9a6-d958-63b2-099738e3dff3@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1802202359090.7674@digraph.polyomino.org.uk>

On 02/20/2018 05:00 PM, Joseph Myers wrote:
> Does this help with any of the cases in bug 80776 that weren't already 
> fixed, or are those distinct despite looking similar?
> 
I don't think so.

THe __builtin_unreachable markers are removed by vrp1 -- well before the
sprintf warning code gets run.

So the sprintf warning code never gets to exploit the properties implied
by the __builtin_unreachable calls.


It doesn't look like VRP records the narrowed ranges implied by the
__builtin_unreachable calls.

After ASSERT_EXPR insertion we have:

;;   basic block 6, loop depth 0, count 1072883002 (estimated locally),
maybe hot
;;    prev block 5, next block 1, flags: (NEW, REACHABLE, VISITED)
;;    pred:       4 [100.0% (guessed)]  count:1072883003 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
  i_7 = ASSERT_EXPR <i_6, (unsigned int) i_6 <= 999999>;
  __builtin___sprintf_chk (&number, 1, 7, "%d", i_7);
  return;

ANd the ranges computed by VRP:


i.0_1: [0, 999999]
i_4: [0, +INF]
i_6: [0, +INF]  EQUIVALENCES: { i_4 } (1 elements)
i_7: [0, 999999]  EQUIVALENCES: { i_4 i_6 } (2 elements)

So VRP does identify the narrow range for i_7.

But then we remove the ASSERT_EXPRs and we're left with:


  i_4 = somerandom ();
  i.0_1 = (unsigned int) i_4;
  __builtin___sprintf_chk (&number, 1, 7, "%d", i_4);
  return;

Subsequent EVRP analysis will start with the range of i_4 as a seed.
BUt there's nothing to further narrow that range.

If ASSERT_EXPR removal could be taught to use i_7 I suspect the right
things would "just happen".  I haven't thought at all about what might
be required to have VRP do-the-right-thing.  Given the overall desire to
drop ASSERT_EXPRs and the range propagation step in VRP in favor of EVRP
style analysis I doubt anyone is likely to spend much time on fixing
this in the old style VRP analysis.

jeff

      reply	other threads:[~2018-02-21  2:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 18:48 Jeff Law
2018-02-21  0:00 ` Joseph Myers
2018-02-21  2:38   ` Jeff Law [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=f218eb8d-d9a6-d958-63b2-099738e3dff3@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.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).