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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |ipa
                 CC|                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-01-28
     Ever confirmed|0                           |1
            Summary|Os does not apply return    |Os causes some functions
                   |value optimization while O2 |which are no-ops not to be
                   |and O3 does                 |inlined in some cases
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This has nothing to do with RVO but rather inlining differences causes the
issue.

So the function which does not get inlined starts with:
void std::_Vector_base<double, std::allocator<double> >::~_Vector_base (struct
_Vector_base * const this)
{
  double * _1;
  double * _2;
  long int _3;
  long unsigned int _10;

  <bb 2> [local count: 1073741824]:
  _2 = this_7(D)->_M_impl.D.21368._M_start;
  if (_2 != 0B)
    goto <bb 3>; [53.47%]
  else
    goto <bb 5>; [46.53%]
...
  <bb 5> [local count: 499612072]:
  goto <bb 4>; [100.00%]
...
  <bb 4> [local count: 1073741824]:
  return;
}

But right before the function call to the deconstructor we have:

  MEM[(struct _Vector_impl_data &)&D.22678]._M_end_of_storage = 0B;
  MEM[(struct _Vector_impl_data &)&D.22678]._M_finish = 0B;
  MEM[(struct _Vector_impl_data &)&D.22678]._M_start = 0B;
  std::_Vector_base<double, std::allocator<double> >::~_Vector_base
(&D.22678.D.22061);

So the deconstructor will be basically gone when inlined.

Reply via email to