[cfe-dev] Inlining dllimport functions

Hamza Sood via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 13 13:04:52 PDT 2018


I’ve looked into it a bit more and it seems like the main optimisation barrier with libc++ on Windows is the extern template usage; it’s preventing a lot of trivial inlining. What about making _LIBCPP_DISABLE_EXTERN_TEMPLATE the default for Windows DLL builds?

> On 13 Sep 2018, at 17:23, Reid Kleckner wrote:
> 
> It would cause problems if 'f' in turn referenced functions that were neither inline nor exported:
> 
> bool not_exported();
> inline bool f() { return not_exported(); }
> __declspec(dllimport) inline bool g() { return f(); }
> 
> I'm pretty sure MSVC will not inline g in this or your example, so I would suggest adjusting dllimport usage patterns to something that satisfies both compilers rather than changing clang.
> 
>> On Thu, Sep 13, 2018 at 8:43 AM Hamza Sood via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>> Currently, Clang won’t inline a dllimport function that references a non-dllimport function. This has a big performance impact on using libc++ on Windows because even something as simple as vector::data() won’t be inlined at the max optimisation level.
>> 
>> Would anything break if Clang were to allow inlining of a dllimport function that references a non-dllimport function that’s also declared inline?
>> 
>> E.g:
>> 
>> inline bool f() { return false; }
>> 
>> __declspec(dllimport) inline bool g() { return f(); }
>> 
>> bool h() {
>>   // can we inline this without issue?
>>   return g();
>> }
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180913/fcc1bbd4/attachment.html>


More information about the cfe-dev mailing list