John Emmas via llvm-dev
2021-Sep-23 15:03 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
On 23/09/2021 15:18, John Emmas via llvm-dev wrote:> > I've used MSVC for maybe 20 years and I've never once known a DLL > function to be inline-able. >On 23/09/2021 15:07, Hans Wennborg wrote:> Actually, MSDN (https://docs.microsoft.com/en-us/cpp/cpp/defining-inline-cpp-functions-with-dllexport-and-dllimport) > documents the opposite: > > "You can also define as inline a function declared with the dllimport > attribute. In this case, the function can be expanded (subject to /Ob > specifications)" > > Of course the reality is more complicated, but it's clear MSVC never > excluded dllimport functions from inlining in general. >Ah... maybe that's the situation - perhaps a DLL function CAN be inlined but only if it's specifically declared as such? That makes a lot of sense and it would also explain why I've never seen it here with ordinary DLL declarations (i.e. those not declared using inline) John
John Emmas via llvm-dev
2021-Sep-24 10:46 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
On 23/09/2021 16:03, John Emmas wrote:> > perhaps a DLL function CAN be inlined but only if it's specifically > declared as such? That makes a lot of sense and it would also explain > why I've never seen it here with ordinary DLL declarations (i.e. those > not declared using inline) >I found this Microsoft document about inlining:- https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view=msvc-160 About half way down there are two examples and the 2nd one states that class member functions which get implemented in a header file are now regarded as being implicitly inlined. This supports Paul's statement yesterday about the One Definition Rule - but what MS doesn't clarify is whether or not that'd also apply to DLL functions. Paul wrote:- On 23/09/2021 14:14, paul.robinson at sony.com wrote:> If MSVC promises not to inline a dllimport method, that seems like > something Clang should take into consideration in MS-compatibility > mode. >Two decades of experience with MSVC suggests that where a dllimport method isn't also declared as 'inline' the compiler won't attempt to inline it. To me that makes perfect sense but frustratingly, I just can't find it in writing anywhere :-( John