<div dir="ltr">That would be a shame. I wouldn't want to throw away such an important code size optimization just because we can't export the things the inline functions reference.<div><br></div><div>I understand it's tough, though. libc++'s visibility and export macros have many consumers, many vendors, many linkage models, and basically too many cooks in the kitchen. I don't have any brilliant suggestions for solving that.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 13, 2018 at 1:05 PM Hamza Sood <<a href="mailto:hamza_sood@me.com">hamza_sood@me.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">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?<br><div dir="ltr"><br>On 13 Sep 2018, at 17:23, Reid Kleckner wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">It would cause problems if 'f' in turn referenced functions that were neither inline nor exported:<div><br></div><div>bool not_exported();</div><div>inline bool f() { return not_exported(); }<br>__declspec(dllimport) inline bool g() { return f(); }<br></div><div><br></div><div>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.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 13, 2018 at 8:43 AM Hamza Sood via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>
<br>
Would anything break if Clang were to allow inlining of a dllimport function that references a non-dllimport function that’s also declared inline?<br>
<br>
E.g:<br>
<br>
inline bool f() { return false; }<br>
<br>
__declspec(dllimport) inline bool g() { return f(); }<br>
<br>
bool h() {<br>
// can we inline this without issue?<br>
return g();<br>
}<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</div></blockquote></div></blockquote></div>