public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101150] null pointer dereference false positive disappears when compiling an additional function
Date: Tue, 22 Jun 2021 00:11:53 +0000	[thread overview]
Message-ID: <bug-101150-4-fsIJjGjVmj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101150-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101150

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.2
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
          Component|c++                         |tree-optimization
   Last reconfirmed|                            |2021-06-22

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There seems to be some missing optimizations (jump threading) here.

First one:

  long int _12;

  _12 = _9 - _15;
  if (_12 != 0)
    goto <bb 4>; [33.00%]
  else
    goto <bb 3>; [67.00%] // this should just jump to bb 15 because _12 == 0
and there for _9 == _15

  <bb 3> [local count: 79134772]:
  if (_9 != _15) /// This should always be false coming from bb 2 because _12
== 0 there for _9 == _15
    goto <bb 11>; [89.00%]
  else
    goto <bb 15>; [11.00%]

...

  <bb 11> [local count: 104641928]:
  # _143 = PHI <_18(8), _9(3)>
  # _118 = PHI <_19(8), _15(3)>
  # v$_M_start_84 = PHI <_104(8), 0B(3)>
  # prephitmp_123 = PHI <_12(8), _12(3)>
  _133 = (unsigned long) _143;
  _110 = (unsigned long) _118;
  _125 = _133 - _110;

....
  <bb 15> [local count: 117575200]:
  return;

Second one:
...

  <bb 4> [local count: 19488414]:
  _64 = (long unsigned int) _12;
  if (_64 > 9223372036854775804)
    goto <bb 5>; [0.04%]
  else
    goto <bb 6>; [99.96%]

....

  <bb 6> [local count: 9740309]:
  if (_12 != 0) // This should always be true as _12 should always != 0 on
coming into this bb because we can only come via the if statement in bb 4 on
the true edge of the conditional.
    goto <bb 7>; [100.00%]
  else
    goto <bb 16>; [0.00%] /// NOTE BB 16 is where the null pointer write it
located

--------- CUT -------
The reason why if you have both foo and bar defined, there is a heuristics of
the inlining of vector::_M_default_append which causes the difference, nothing
shocking really.

  reply	other threads:[~2021-06-22  0:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 11:48 [Bug c++/101150] New: " adl at gnu dot org
2021-06-22  0:11 ` pinskia at gcc dot gnu.org [this message]
2021-07-28  7:07 ` [Bug tree-optimization/101150] [11/12 Regression] " rguenth at gcc dot gnu.org
2022-01-20 12:55 ` rguenth at gcc dot gnu.org
2022-04-21  7:49 ` rguenth at gcc dot gnu.org
2023-03-23 18:05 ` [Bug tree-optimization/101150] [11/12/13 " pinskia at gcc dot gnu.org
2023-05-29 10:05 ` [Bug tree-optimization/101150] [11/12 " jakub at gcc dot gnu.org

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=bug-101150-4-fsIJjGjVmj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).