public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc
@ 2020-05-05 22:41 jsm28 at gcc dot gnu.org
  2020-05-06  7:38 ` [Bug tree-optimization/94963] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2020-05-05 22:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94963
           Summary: [11 Regression] Spurious uninitialized warning for
                    static variable building glibc
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsm28 at gcc dot gnu.org
  Target Milestone: ---

r11-39-gf9e1ea10e657af9fb02fafecf1a600740fd34409 ("tree-optimization/39612 -
avoid issueing loads in SM when possible") introduces a spurious warning
building the following code (reduced from glibc) with -O2 -Wall (for
aarch64-linux-gnu at least, probably for other targets.  The warning is
obviously bogus because it relates to a field of a static variable, which is
always initialized.

uninit.c: In function 'f':
uninit.c:30:6: warning: 'var_field_lsm.8' may be used uninitialized in this
function [-Wmaybe-uninitialized]
   30 |   if (var.field != 0)
      |      ^


Reduced testcase:

typedef struct
{
  int p1;
  int p2;
  int p3;
} P;
struct S
{
  int field;
};
extern int v2;
extern void foo (struct S *map);
static struct S var;
const P *pv;
int ps;
void
f (void)
{
  if (pv != 0)
    for (const P *ph = pv; ph < &pv[ps]; ++ph)
      switch (ph->p1)
        {
        case 1:
          v2 = ph->p2;
          break;
        case 2:
          var.field = ph->p3;
          break;
        }
  if (var.field != 0)
    foo (&var);
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/94963] [11 Regression] Spurious uninitialized warning for static variable building glibc
  2020-05-05 22:41 [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc jsm28 at gcc dot gnu.org
@ 2020-05-06  7:38 ` rguenth at gcc dot gnu.org
  2020-05-06  7:55 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-06  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-05-06
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  I've met the underlying issue when developing the patch and for
this reason marked the conditional store inserted by LIM with no-warning.
But for the testcase that's not enough since now PRE comes along and
optimizes the var.field load away, re-exposing the issue.

LIM transforms the testcase to (simplified a bit)

void
f (void)
{
  if (pv != 0)
    {
      bool v2_set = false;
      bool varfield_set = false;
      int v2tem, varfield_tem;
    for (const P *ph = pv; ph < &pv[ps]; ++ph)
      switch (ph->p1)
        {
        case 1:
          v2tem = ph->p2;
          v2_set = true;
          break;
        case 2:
          varfield_tem = ph->p3;
          varfield_set = true;
          break;
        }
      if (varfield_set)
        var.field = varfield_tem;
      if (v2_set)
        v2 = v2tem;
     }
  if (var.field != 0)
    foo (&var);
}

where the uninit predicate analysis doesn't grok the relation between
varfield_set and varfield_tem being initialized.

The patch changed code generation to elide the previously emitted
unconditional load of v2 and var.field.  I suspected that for
the case where there is no load the loop PHI for varfield_tem
might be eliminated, but it is not in all cases it seems.  Now
apart from marking the store no-warning we could easily initialize
the tems on loop entry, just not with their true value but for example
with zero.  That might result in less optimal out-of-SSA though
(no coalescing with constants, the constant move needs to be emitted...)
at least when the loop PHI is not eliminated.

What works is initializing with an uninitialized variable marked
TREE_NO_WARNING.  I'm going to test that (eliding the no-warning
on the conditional stores).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/94963] [11 Regression] Spurious uninitialized warning for static variable building glibc
  2020-05-05 22:41 [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc jsm28 at gcc dot gnu.org
  2020-05-06  7:38 ` [Bug tree-optimization/94963] " rguenth at gcc dot gnu.org
@ 2020-05-06  7:55 ` rguenth at gcc dot gnu.org
  2020-05-06 10:36 ` cvs-commit at gcc dot gnu.org
  2020-05-06 10:37 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-06  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 48459
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48459&action=edit
patch in testing

Testing the attached.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/94963] [11 Regression] Spurious uninitialized warning for static variable building glibc
  2020-05-05 22:41 [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc jsm28 at gcc dot gnu.org
  2020-05-06  7:38 ` [Bug tree-optimization/94963] " rguenth at gcc dot gnu.org
  2020-05-06  7:55 ` rguenth at gcc dot gnu.org
@ 2020-05-06 10:36 ` cvs-commit at gcc dot gnu.org
  2020-05-06 10:37 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-06 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:371905d12259c180efb9b1f1b5716e969feb60f9

commit r11-138-g371905d12259c180efb9b1f1b5716e969feb60f9
Author: Richard Biener <rguenther@suse.de>
Date:   Wed May 6 09:39:45 2020 +0200

    tree-optimization/94963 - avoid bogus uninit warning with store-motion

    Eliding the load for store-motion causes an uninitialized variable
    flowing into the loop, conditionally initialized and used.  The
    uninit warning cannot relate the flag used to guard the initialization
    and use with the actual initialization so the following robustifies
    the previous approach of marking the conditional store as not to
    be warned on by instead initializing the variable on loop entry
    from an uninitialized variable we mark as not to be warned for.

    2020-05-06  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/94963
            * tree-ssa-loop-im.c (execute_sm_if_changed): Remove
            no-warning marking of the conditional store.
            (execute_sm): Instead mark the uninitialized state
            on loop entry to be not warned about.

            * gcc.dg/pr94963.c: New testcase.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/94963] [11 Regression] Spurious uninitialized warning for static variable building glibc
  2020-05-05 22:41 [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc jsm28 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-05-06 10:36 ` cvs-commit at gcc dot gnu.org
@ 2020-05-06 10:37 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-06 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Should be fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-06 10:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 22:41 [Bug tree-optimization/94963] New: [11 Regression] Spurious uninitialized warning for static variable building glibc jsm28 at gcc dot gnu.org
2020-05-06  7:38 ` [Bug tree-optimization/94963] " rguenth at gcc dot gnu.org
2020-05-06  7:55 ` rguenth at gcc dot gnu.org
2020-05-06 10:36 ` cvs-commit at gcc dot gnu.org
2020-05-06 10:37 ` rguenth at gcc dot gnu.org

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).