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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Here's a simple C++ example using std::function that illustrates the same
thing.  The call to h below is optimized away, but two now-unused static member
functions _M_invoke and _M_manager remain in the optimized code.


#include <functional>

int
m ()
{
  std::function<int(int)> h = [] (int i) { return i - 1; };
  return h (5);
}


-fdump-tree-optimized:
;; Function std::_Function_handler<int(int), m()::<lambda(int)> >::_M_invoke
(_ZNSt17_Function_handlerIFiiEZ1mvEUliE_E9_M_invokeERKSt9_Any_dataOi,
funcdef_no=1738, decl_uid=33290, cgraph_uid=651, symbol_order=654)

std::_Function_handler<int(int), m()::<lambda(int)> >::_M_invoke (const union
_Any_data & {ref-all} __functor, int & __args#0)
{
  ...
}
;; Function std::_Function_base::_Base_manager<m()::<lambda(int)> >::_M_manager
(_ZNSt14_Function_base13_Base_managerIZ1mvEUliE_E10_M_managerERSt9_Any_dataRKS3_St18_Manager_operation,
funcdef_no=1739, decl_uid=33254, cgraph_uid=652, symbol_order=655)

Removing basic block 7
Removing basic block 9
std::_Function_base::_Base_manager<m()::<lambda(int)> >::_M_manager (union
_Any_data & {ref-all} __dest, const union _Any_data & {ref-all} __source,
_Manager_operation __op)
{
  ...
}

;; Function m (_Z1mv, funcdef_no=1392, decl_uid=31150, cgraph_uid=311,
symbol_order=314)

m ()
{
  <bb 2> [local count: 1073741824]:
  return 4;

}

Reply via email to