Is there a point in specifying calling convention for an inline function? For example, I am writing SIMD math library, where it is recommended to use __vectorcall
, but all of my functions are inline. In some articles I have seen people inlining all function and still saying, that you need to compile the library with default __vectorcall
convention (or actually putting this attribute).
I can see the difference in assembly, when function is not inline. But what is the point to specify calling convention for inline function since it is not really a function call? Isn't it better to specify __vectorcall
only for not inline function?
The inline keyword is only a suggestion to the compiler; it doesn't guarantee that the function will be inlined. For example, a recursive function can't be inlined, and if you use function pointers the compiler may need to generate non-inline copies of otherwise inlined functions. Additionally, constraints on memory and space might stop the compiler from inlining a function.
As a result, even if you mark a function inline, you'll still to specify a calling convention if appropriate because there's no guarantee that the compiler will indeed eliminate the function call.