Inlining
This will be a shorter post, but I hope it will serve to establish an important rule about inlining, which is that in Heck I plan to standardize forcing the compiler to inline any function with the inline qualifier, and if it's unable to do so, an error must be reported.
In my last post I established the idea that optimization should be under the user's control, so if they choose to inline a function, it should always be inlined.
I don't like the fact that C++ doesn't guarantee that functions are inlined when they are labeled as such. It shouldn't be up to the compiler whether or not to inline a function when it was told to, especially in a language where users are supposed to have some control over the binaries that are produced.
The instances where a function is not inlined when given the qualifier is only acceptable when it's absolutely necessary. For example, a recursive function cannot be inlined because that would generate an infinite amount of code. This rule would have to extend to indirect recursion, e.g. an inlined function that calls another inlined function which then calls the original function, which would also generate an infinite amount code.
I suppose recursive functions could be inlined somehow, but the Heck standard will only guarantee inlining for functions that are not recursive, at least initially, and any code that does inline a recursive function should not be considered portable.
In my last post I established the idea that optimization should be under the user's control, so if they choose to inline a function, it should always be inlined.
I don't like the fact that C++ doesn't guarantee that functions are inlined when they are labeled as such. It shouldn't be up to the compiler whether or not to inline a function when it was told to, especially in a language where users are supposed to have some control over the binaries that are produced.
The instances where a function is not inlined when given the qualifier is only acceptable when it's absolutely necessary. For example, a recursive function cannot be inlined because that would generate an infinite amount of code. This rule would have to extend to indirect recursion, e.g. an inlined function that calls another inlined function which then calls the original function, which would also generate an infinite amount code.
I suppose recursive functions could be inlined somehow, but the Heck standard will only guarantee inlining for functions that are not recursive, at least initially, and any code that does inline a recursive function should not be considered portable.
Comments
Post a Comment