By: anon2 (anon.delete@this.anon.com), July 3, 2021 12:10 am
Room: Moderated Discussions
Adrian (a.delete@this.acm.org) on July 2, 2021 10:03 pm wrote:
> anon2 (anon.delete@this.anon.com) on July 2, 2021 7:49 pm wrote:
> > Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 2, 2021 2:10 pm wrote:
> > >
> > > So on ARM64, there's a natural wish to maybe use more registers for argument passing etc.
> > > But particularly if you use LTO, you can still use a more limited "official" calling convention,
> > > and then do something else for local calls that aren't externally visible.
> >
> > Do any compilers actually do this? I don't mean inline or partial inline to create a
> > different function, but compiling a given function with different call convention?
> >
> > Not saying it would be difficult or not worthwhile for a compiler
> > to do. Would have to be careful looking at the assembly though!
>
>
>
> I am not sure whether your question was about compilers choosing a call
> convention by themselves, or only when the programmer specifies that.
The former. And to rwessel's comment yes I do know about IPA including register allocation in literature (it was a usual if not highly detailed chapter of basic compiler books decades ago IIRC). I just wonder if any (common) compilers do it today.
>
>
> In old 32-bit x86 libraries written in C or C++, it was not uncommon to have a
> mix of calling conventions, with the calling convention specified for each function
> by the programmer, using attributes like "fastcall", "pascal" or "cdecl".
>
>
> There are also compilers for various programming languages
> that have the option to do "whole program optimization".
>
> If that is chosen, then the compiler translates the compilation units from all the source files
> simultaneously, generating the complete executable file, so the compiler is free to choose for
> each function a custom calling convention, i.e. each function may use different registers for
> passing the arguments and it may also save different registers than other functions.
I am most interested in C / "ELF" ABI type of compilers here, but would be interesting to hear about others too. Which ones do this?
>
>
> While the current compilers for more mainstream programming languages like C/C++ also have some options
> for "whole program optimization" or LTO, those are more limited and I do not have experience with them,
> so I do not know if they also may use customized calling conventions for some functions.
>
>
>
>
> anon2 (anon.delete@this.anon.com) on July 2, 2021 7:49 pm wrote:
> > Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 2, 2021 2:10 pm wrote:
> > >
> > > So on ARM64, there's a natural wish to maybe use more registers for argument passing etc.
> > > But particularly if you use LTO, you can still use a more limited "official" calling convention,
> > > and then do something else for local calls that aren't externally visible.
> >
> > Do any compilers actually do this? I don't mean inline or partial inline to create a
> > different function, but compiling a given function with different call convention?
> >
> > Not saying it would be difficult or not worthwhile for a compiler
> > to do. Would have to be careful looking at the assembly though!
>
>
>
> I am not sure whether your question was about compilers choosing a call
> convention by themselves, or only when the programmer specifies that.
The former. And to rwessel's comment yes I do know about IPA including register allocation in literature (it was a usual if not highly detailed chapter of basic compiler books decades ago IIRC). I just wonder if any (common) compilers do it today.
>
>
> In old 32-bit x86 libraries written in C or C++, it was not uncommon to have a
> mix of calling conventions, with the calling convention specified for each function
> by the programmer, using attributes like "fastcall", "pascal" or "cdecl".
>
>
> There are also compilers for various programming languages
> that have the option to do "whole program optimization".
>
> If that is chosen, then the compiler translates the compilation units from all the source files
> simultaneously, generating the complete executable file, so the compiler is free to choose for
> each function a custom calling convention, i.e. each function may use different registers for
> passing the arguments and it may also save different registers than other functions.
I am most interested in C / "ELF" ABI type of compilers here, but would be interesting to hear about others too. Which ones do this?
>
>
> While the current compilers for more mainstream programming languages like C/C++ also have some options
> for "whole program optimization" or LTO, those are more limited and I do not have experience with them,
> so I do not know if they also may use customized calling conventions for some functions.
>
>
>
>