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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mjambor at suse dot cz

--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Hello,
I looked at the flifetime-dse testcase. It is missed optimization because C++
FE does not place clobbers after explicit dtor calls and IPA-SRA thinks it is
good idea to kill them (which I think would be if C++ FE placed the clobbers
into callers).

Jason, is there chance to update C++ FE here?

It is a missed optimization. What happens is that with Darwin we decide to
apply SRA on:
;; Function A::A (_ZN1AC1Ev, funcdef_no=3, decl_uid=2333, cgraph_uid=4,
symbol_order=3)

A::A (struct A * const this)
{
  <bb 2> :
  *this_2(D) ={v} {CLOBBER};
  return;

}
;; Function A::~A (_ZN1AD1Ev, funcdef_no=6, decl_uid=2337, cgraph_uid=7,
symbol_order=6)

A::~A (struct A * const this)
{
  <bb 2> :
  *this_2(D) ={v} {CLOBBER};
  return;

}

which leads to

A::_ZN1AC1Ev.isra.0 ()
{
  struct A * const this;

  <bb 3> :

  <bb 2> :
  return;

}

A::_ZN1AD1Ev.isra.0 ()
{
  struct A * const this;

  <bb 3> :

  <bb 2> :
  return;

}


and after inlining we no longer see the clobber.  I wonder why this does not
happen everwhere?

I also would have expected C++ FE to produce clobber after the constructor call
so we can DSE even w/o inlining the constructor, but this is not the case as
seen in the early SRA dump:

main ()
{
  struct A * ap;
  int ar[1];
  int _1;
  int _2;
  void * _6;
  int _12;

  <bb 2> :
  ar[0] = 42;
  _6 = operator new (4, &ar);
  A::A (_6);
  ap_8 = _6;
  _1 = ap_8->i;
  if (_1 == 42)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  __builtin_abort ();

  <bb 4> :
  ap_8->i = 42;
  A::~A (ap_8);
  _2 = ar[0];
  if (_2 == 42)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  __builtin_abort ();

  <bb 6> :
  ar ={v} {CLOBBER};
  _12 = 0;
  return _12;

}
The clobber is placed at the end of scope block. Perhaps it is because
destructor is called explicitly? Can still C++ FE place clobbers in this case?

Honza

Reply via email to