public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__
       [not found] <bug-84078-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-05 17:10 ` msebor at gcc dot gnu.org
  2022-11-20  4:16 ` law at gcc dot gnu.org
  2022-11-28 22:35 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-05 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0, 11.0, 4.1.0, 4.8.4,
                   |                            |4.9.4, 5.5.0, 6.4.0, 7.2.0,
                   |                            |8.3.0, 9.1.0
           Keywords|                            |missed-optimization
   Last reconfirmed|2018-01-29 00:00:00         |2021-4-5
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirmed with GCC 11 and -O1/-O2 and the slightly reduced test case below. 
I don't see anything in the IL that could be used to prove the uninitialized
variable isn't used: a_3 is uninitialized when b_6 != 0 || x == 0, and a_3 is
used when b_2 == 0 && c_9 == 0.  The two predicates aren't mutually exclusive
so the warning triggers.

$ cat pr84078.c && gcc -O2  -S -Wall -fdump-tree-uninit=/dev/stdout pr84078.c
int x, z;

int f (void);

void g (int b)
{
  int a;

  if (!b)
    {
      if (x)
        a = x;
      else
        b = 1;
    }

  {
    int c;
    __asm __volatile("" : "=r" (c));
    if (c)
      f ();
  }

  if (b)
    return;

  z = a;
}

;; Function g (g, funcdef_no=0, decl_uid=1947, cgraph_uid=1, symbol_order=2)

[AFTER NORMALIZATION -- [DEF]:
 (.NOT.) b_6(D) == 0


[AFTER NORMALIZATION -- [DEF]:
a_3 = PHI <a_7(D)(10), x.0_1(11), a_7(D)(4)>
is guarded by :

x.0_1 != 0 (.AND.) b_6(D) == 0


[AFTER NORMALIZATION -- [USE]:
z = a_3;
is guarded by :

 (.NOT.) b_2 != 0


pr84078.c: In function ‘g’:
pr84078.c:27:5: warning: ‘a’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   27 |   z = a;
      |   ~~^~~
pr84078.c:7:7: note: ‘a’ was declared here
    7 |   int a;
      |       ^
void g (int b)
{
  int c;
  int a;
  int x.0_1;

  <bb 2> [local count: 1073741824]:
  if (b_6(D) == 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 10>; [50.00%]

  <bb 10> [local count: 536870912]:
  goto <bb 5>; [100.00%]

  <bb 3> [local count: 536870913]:
  x.0_1 = x;
  if (x.0_1 != 0)
    goto <bb 11>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 11> [local count: 268435457]:
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 268435457]:

  <bb 5> [local count: 1073741824]:
  # b_2 = PHI <b_6(D)(10), 0(11), 1(4)>
  # a_3 = PHI <a_7(D)(10), x.0_1(11), a_7(D)(4)>
  __asm__ __volatile__("" : "=r" c_9);
  if (c_9 != 0)
    goto <bb 6>; [33.00%]
  else
    goto <bb 12>; [67.00%]

  <bb 12> [local count: 719407024]:
  goto <bb 7>; [100.00%]

  <bb 6> [local count: 354334800]:
  f ();

  <bb 7> [local count: 1073741824]:
  if (b_2 != 0)
    goto <bb 13>; [34.00%]
  else
    goto <bb 8>; [66.00%]

  <bb 13> [local count: 365072224]:
  goto <bb 9>; [100.00%]

  <bb 8> [local count: 708669601]:
  z = a_3;

  <bb 9> [local count: 1073741824]:
  return;

}

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

* [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__
       [not found] <bug-84078-4@http.gcc.gnu.org/bugzilla/>
  2021-04-05 17:10 ` [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__ msebor at gcc dot gnu.org
@ 2022-11-20  4:16 ` law at gcc dot gnu.org
  2022-11-28 22:35 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: law at gcc dot gnu.org @ 2022-11-20  4:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |law at gcc dot gnu.org

--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Seems to have been fixed on the trunk.  Not sure if it was the Aldy's threader
work or Richi's predicate analysis work.  Either is plausible.  Just happy it's
fixed.

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

* [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__
       [not found] <bug-84078-4@http.gcc.gnu.org/bugzilla/>
  2021-04-05 17:10 ` [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__ msebor at gcc dot gnu.org
  2022-11-20  4:16 ` law at gcc dot gnu.org
@ 2022-11-28 22:35 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

end of thread, other threads:[~2022-11-28 22:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-84078-4@http.gcc.gnu.org/bugzilla/>
2021-04-05 17:10 ` [Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__ msebor at gcc dot gnu.org
2022-11-20  4:16 ` law at gcc dot gnu.org
2022-11-28 22:35 ` pinskia 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).