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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-01-22
     Ever confirmed|0                           |1

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So this boils down to a missed optimization (as many cases do...).  The
uninit warning sees

<bb 2> [local count: 1073741825]:
_3 = bar ();
future_state::future_state (&_local_state);
MEM[(struct  &)&_local_state] ={v} {CLOBBER};
MEM[(struct optional *)&_local_state]._M_engaged = 0;
MEM[(struct optional *)_3]._M_engaged = 0;
_7 = MEM[(struct optional &)&_local_state]._M_engaged;
if (_7 != 0)
  goto <bb 3>; [50.00%]
else
  goto <bb 5>; [50.00%]

<bb 3> [local count: 536870912]:
_6 = MEM[(struct temporary_buffer &)&_local_state]._buffer;
...

and warns about the load _6 = ...

As you can see the condition isn't elided and somehow we didn't manage to CSE
the load of _M_engaged here, possibly due to the appearant aliasing of
the store via _3.  points-to analysis explicitely says it might alias
_local_state because _local_state escapes to future_state::future_state
and PTA is not flow-sensitive:

  <bb 2> [local count: 1073741825]:
  # PT = nonlocal escaped null
  # USE = nonlocal null { D.2493 } (escaped)
  # CLB = nonlocal null { D.2493 } (escaped)
  _3 = bar ();
  # USE = nonlocal null { D.2493 } (escaped)
  # CLB = nonlocal null { D.2493 } (escaped)
  future_state::future_state (&_local_stateD.2493);
  MEM[(struct  &)&_local_stateD.2493] ={v} {CLOBBER};
  MEM[(struct optionalD.2409 *)&_local_stateD.2493]._M_engagedD.2426 = 0;
  MEM[(struct optionalD.2409 *)_3]._M_engagedD.2426 = 0;

Reply via email to