[Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__

2022-11-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84078

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |13.0

[Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__

2022-11-19 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84078

Jeffrey A. Law  changed:

   What|Removed |Added

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

--- Comment #3 from Jeffrey A. Law  ---
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.

[Bug middle-end/84078] false positive for -Wmaybe-uninitialized with __asm__

2021-04-05 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84078

Martin Sebor  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  ---
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 
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;

   [local count: 1073741824]:
  if (b_6(D) == 0)
goto ; [50.00%]
  else
goto ; [50.00%]

   [local count: 536870912]:
  goto ; [100.00%]

   [local count: 536870913]:
  x.0_1 = x;
  if (x.0_1 != 0)
goto ; [50.00%]
  else
goto ; [50.00%]

   [local count: 268435457]:
  goto ; [100.00%]

   [local count: 268435457]:

   [local count: 1073741824]:
  # b_2 = PHI 
  # a_3 = PHI 
  __asm__ __volatile__("" : "=r" c_9);
  if (c_9 != 0)
goto ; [33.00%]
  else
goto ; [67.00%]

   [local count: 719407024]:
  goto ; [100.00%]

   [local count: 354334800]:
  f ();

   [local count: 1073741824]:
  if (b_2 != 0)
goto ; [34.00%]
  else
goto ; [66.00%]

   [local count: 365072224]:
  goto ; [100.00%]

   [local count: 708669601]:
  z = a_3;

   [local count: 1073741824]:
  return;

}