Sujet : Re: Calling conventions (particularly 32-bit ARM)
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.archDate : 09. Jan 2025, 22:23:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlpeoi$3hjos$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : slrn/1.0.3 (Linux)
MitchAlsup1 <
mitchalsup@aol.com> schrieb:
On Thu, 9 Jan 2025 7:23:57 +0000, Anton Ertl wrote:
>
Stefan Monnier <monnier@iro.umontreal.ca> writes:
[Someone wrote:]
ABI calling conventions tend to be designed to support at least C,
including varargs and often also tolerant of differences between the
number of arguments in the caller and callee.
>
I can agree that it's important to support those use-cases (varargs
obviously, mismatched arg numbers less so),
>
You are head of a group of people who design a new architecture (say,
it's 2010 and you design ARM A64, or it's 2014 and you design RISC-V).
Your ABI designer comes to you and tells you that his life would be
easier if it was ok that programs with mismatched arguments don't need
to work. Would you tell him that they don't need to work?
>
No, I would stand my ground and mandate that they do work.
That can be tricky. You can read
https://blog.r-project.org/2019/05/15/gfortran-issues-with-lapack/index.htmland its sequel
https://blog.r-project.org/2019/09/25/gfortran-issues-with-lapack-ii/as a cautionary tale.
To cut this a little shorter: Assume eight arguments are passed in
registers, like for My 66000.
Caller calls
foo (a1, a2, a3, a4, a5, a6, a7, a8);
Callee side:
foo (a1, a2, a3, a4, a5, a6, a7, a8, a9)
Foo ends with
bar (b1, b2, b3, b4, b5, b6, b7, b8, b9);
and wants to save stack space, so it stores the value of b9 into
the space where it was supposed to be, and then branches to bar.
Result: Stack corruption.
What would you tell your ABI designer in that case? Don't do tail
calls, it is better to use more stack space, with all effect on
stack sizes and locality that would have?