[cfe-dev] Inlining dllimport functions

Nico Weber via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 13 09:52:07 PDT 2018


Does https://reviews.llvm.org/D51340 enable this?

On Thu, Sep 13, 2018 at 12:24 PM Reid Kleckner via cfe-dev <
cfe-dev at lists.llvm.org> 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
>>
> _______________________________________________
> 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/bafa1d87/attachment.html>


More information about the cfe-dev mailing list