public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/97108] [9/10/11/12 Regression] -Wmaybe-uninitialized false positive
Date: Tue, 30 Nov 2021 16:33:23 +0000	[thread overview]
Message-ID: <bug-97108-4-cFQB7woK73@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97108-4@http.gcc.gnu.org/bugzilla/>

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |101912
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |amacleod at redhat dot com,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #5 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #1)

> The backwards threader probably could be made to detect this case though. 
> I'm pretty sure we're not raising queries for COND_EXPRs  on the RHS of a
> statement, just for GIMPLE_COND statements.  So this block:
> 
> ;;   basic block 9, loop depth 0, count 708669601 (estimated locally), maybe
> hot
> ;;    prev block 8, next block 10, flags: (NEW, VISITED)
> ;;    pred:       8 [always]  count:346397698 (estimated locally)
> (FALLTHRU,EXECUTABLE)
> ;;                7 [51.1% (guessed)]  count:362271902 (estimated locally)
> (FALSE_VALUE,EXECUTABLE)
>   _2 = orig_err_26 != 2;
>   _1 = flags_8(D) == 0;
>   _3 = _2 & _1;
>   if (_3 != 0)
>     goto <bb 10>; [33.00%]
>   else
>     goto <bb 4>; [67.00%]

The original code gates the read from orig_err with !separate_stderr:

      if (separate_stderr
          && orig_err != STDERR_FILENO)
        _close (orig_err);

which is somehow lost in BB9 above, since the reads from both orig_err_26 and
separate_stderr (!flags) are occuring in the same block.

I've made a similar observation in PR101912.  I assume this eliding of the gate
is allowable per language rules?

However, even if the gate were there, I think we'd start to run into path
length issues.  For example, I see some of the paths starting at the 3->5 edge
(which contains the undefined read):

Checking profitability of path (backwards):  bb:9 (4 insns) bb:7 (2 insns) bb:6
(2 insns) bb:5 (3 insns) bb:3
  Control statement insns: 2
  Overall: 9 insns
  FAIL: Did not thread around loop and would copy too many statements.

So I'm not even sure we could depend on the threader catching this since it's
handcuffed from attempting such long paths.

Crazy idea, but I wonder if we could plug the path solver to the uninit code. 
For instance, if we're going to warn on a use of orig_err_26, first query all
the paths from DEF to USE and see if any are reachable.  This would be cheaper
than a full blown threader, since we've only be chasing paths for places we're
already going to warn on.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101912
[Bug 101912] -Wmaybe-uninitialized false alarm in tzdb localtime.c

  parent reply	other threads:[~2021-11-30 16:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 12:32 [Bug tree-optimization/97108] New: Wmaybe-uninitialized " clyon at gcc dot gnu.org
2020-11-06 23:58 ` [Bug tree-optimization/97108] " law at redhat dot com
2021-04-09 23:37 ` msebor at gcc dot gnu.org
2021-04-09 23:41 ` [Bug tree-optimization/97108] [9/10/11 Regression] -Wmaybe-uninitialized " msebor at gcc dot gnu.org
2021-04-19  7:20 ` rguenth at gcc dot gnu.org
2021-06-01  8:18 ` [Bug tree-optimization/97108] [9/10/11/12 " rguenth at gcc dot gnu.org
2021-11-30 16:33 ` aldyh at gcc dot gnu.org [this message]
2022-05-27  9:43 ` [Bug tree-optimization/97108] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
2023-01-09 11:20 ` rguenth at gcc dot gnu.org
2023-04-12 13:30 ` sjames at gcc dot gnu.org
2023-07-04  9:19 ` [Bug tree-optimization/97108] [10/11/12/13/14 " rguenth at gcc dot gnu.org
2023-07-07 10:38 ` [Bug tree-optimization/97108] [11/12/13/14 " rguenth 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-97108-4-cFQB7woK73@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).