John Emmas via llvm-dev
2021-Sep-22 13:14 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
On 22/09/2021 13:53, Eric Astor wrote:> > Just as John suggested, disassembling the output shows that clang is > inlining this function, even at -O1, where MSVC doesn't, even at /O3. > > [...] > > One possible workaround: add a noinline marker on functions defined in > headers that need to access protected members. > (https://godbolt.org/z/Pe67ovMnP) >Many thanks Eric, I'm not quite sure what the difference is between LLVM and Clang so sorry if I'm getting them mixed up - but is there a possible fix by just extending the implementation for your "/Ob0" handler? In other words, if "/Ob0" gets specified during compilation, the compiler would stop trying to inline things? John
via llvm-dev
2021-Sep-22 14:00 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
> I'm not quite sure what the difference is between LLVM and Clang so > sorry if I'm getting them mixed up - but is there a possible fix by just > extending the implementation for your "/Ob0" handler? In other words, > if "/Ob0" gets specified during compilation, the compiler would stop > trying to inline things?It looks like the driver does translate "/Ob0" to the internal option "-fno-inline" which ought to prevent inlining of anything that is not marked as always-inline; I am pretty sure that simply being defined in-class does not qualify. I tried your example on my machine locally (adding a function that calls get_keyboard) and it did not inline the call. I don't know why this result differs from Eric's. --paulr