http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59948
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-01-29 CC| |hubicka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Honza will know the correct condition ... As for optimization the issue is that <bb 2>: MEM[(struct _Function_base *)&h]._M_manager = 0B; MEM[(int (*<T5869>) (int) *)&h] = f; h._M_invoker = _M_invoke; h.D.26161._M_manager = _M_manager; _4 = std::function<int(int)>::operator() (&h, 1); <bb 3>: _5 = _4; _11 = MEM[(struct _Function_base *)&h]._M_manager; if (_11 != 0B) goto <bb 4>; else goto <bb 5>; <bb 4>: _11 (&MEM[(struct _Function_base *)&h]._M_functor, &MEM[(struct _Function_base *)&h]._M_functor, 3); the call to std::function<int(int)>::operator() (&h, 1) may clobber h and thus the _M_manager field. This function is not early-inlined at -O[23] and thus the call is not made direct before IPA inlining (or earlier). Considering inline candidate _Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = int; _ArgTypes = {int}]. Estimating body: _Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = int; _ArgTypes = {int}]/360 Known to be false: not inlined size:10 time:21 Estimating body: _Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = int; _ArgTypes = {int}]/360 Known to be false: not inlined size:10 time:21 will not early inline: int m()/273->_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = int; _ArgTypes = {int}]/360, growth 6 exceeds --param early-inlining-insns divided by number of calls forcing that with --param early-inlining-insns=100 arrives at <bb 2>: MEM[(struct _Function_base *)&h]._M_manager = 0B; MEM[(int (*<T5869>) (int) *)&h] = f; h._M_invoker = _M_invoke; h.D.26161._M_manager = _M_manager; _14 = std::_Function_handler<int(int), int (*)(int)>::_M_invoke (&h.D.26161._M_functor, 1); <bb 3>: _15 = MEM[(struct _Function_base *)&h]._M_manager; which has the same problem - just with another function call which the early inliner doesn't see.