By: Carson (carson.delete@this.example.edu), July 4, 2021 1:23 pm
Room: Moderated Discussions
anon2 (anon.delete@this.anon.com) on July 3, 2021 9:18 pm wrote:
> Yeah, you could be right depending on how you read my question, and yes it is an example of a context
> specific calling convention. The function is always compiled with the same calling convention(s)
> though, standard ABI is used, and after the global prologue it looks exactly the same, and it can
> be called by any caller. It actually wouldn't surprise me if a "fastcall" or "asmlinkage" kind
> of optimization for static functions was applied by very old x86 compilers either.
>
> What I intended to ask is whether analysis is applied to change the call convention
> of a particular function, arguments, return value registers, etc based not just
> on local/global, but a co-optimization between callers and callee.
Ah, you're interested in the "callee convention" half of the calling convention. :-)
The most glaringly obvious one is inlining: get rid of the call instruction entirely.
Another one, used heavily in OO languages, is specialization: generate a monomorphic variant of a polymorphic function.
Many compilers can do the same with other constant-time parameters (not just type parameters).
Unless it can identify every call site, a compiler usually has to generate a generic version of such functions, too.
> Yeah, you could be right depending on how you read my question, and yes it is an example of a context
> specific calling convention. The function is always compiled with the same calling convention(s)
> though, standard ABI is used, and after the global prologue it looks exactly the same, and it can
> be called by any caller. It actually wouldn't surprise me if a "fastcall" or "asmlinkage" kind
> of optimization for static functions was applied by very old x86 compilers either.
>
> What I intended to ask is whether analysis is applied to change the call convention
> of a particular function, arguments, return value registers, etc based not just
> on local/global, but a co-optimization between callers and callee.
Ah, you're interested in the "callee convention" half of the calling convention. :-)
The most glaringly obvious one is inlining: get rid of the call instruction entirely.
Another one, used heavily in OO languages, is specialization: generate a monomorphic variant of a polymorphic function.
Many compilers can do the same with other constant-time parameters (not just type parameters).
Unless it can identify every call site, a compiler usually has to generate a generic version of such functions, too.