[llvm-dev] Inline constant std::function parameter

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Tue May 29 11:53:41 PDT 2018


On 5/29/2018 10:52 AM, Eleftherios Ioannidis via llvm-dev wrote:
> However that doesn't seem to be the case, does the inliner not get triggered if the functions are passed as objects (std::function) or am I using the wrong `opt` invokation?

In general, the inliner can only inline direct function calls (not 
virtual calls, or calls through a function pointer or std::function); 
otherwise, it doesn't know what to inline.

In some cases, optimizations can prove that an indirect call actually 
calls some specific function, but your testcase isn't one of those 
cases.  In particular, the implementation of std::function is kind of 
hard for the optimizer to deal with. This could probably be improved.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list