[Bug c++/64150] Missed optimisation opportunity with moved-from pimpl classes and a nullptr d-pointer

2014-12-02 Thread marc at kdab dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64150

--- Comment #1 from marc at kdab dot com ---
(compiled with g++ -fverbose-asm -std=c++14 -g -O3 -S -o
test-moved-from-dtor.{s,cpp})


[Bug c++/64150] Missed optimisation opportunity with moved-from pimpl classes and a nullptr d-pointer

2014-12-02 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64150

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from Richard Biener rguenth at gcc dot gnu.org ---
  bb 2:
  p1 = makePimpled (); [return slot optimization]
  _7 = p1.d;
  p2.d = _7;
  p1.d = 0B;
  if (_7 != 0B)
goto bb 3;
  else
goto bb 4;

  bb 3:
  Pimpled::destroy (p2);

  bb 4:
  p2 ={v} {CLOBBER};
  _3 = p1.d;
  if (_3 != 0B)

there is nothing that prevents makePimpled from storing a reference to p1
somewhere where Pimpled::destroy could modify it.

Thus it is not valid to assume that p1.d is still null at the if.