Deutsch   English   Français   Italiano  
<vlpeoi$3hjos$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Thomas Koenig <tkoenig@netcologne.de>
Newsgroups: comp.arch
Subject: Re: Calling conventions (particularly 32-bit ARM)
Date: Thu, 9 Jan 2025 21:23:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <vlpeoi$3hjos$1@dont-email.me>
References: <vlgngv$1ks4a$1@dont-email.me>
 <4903307dfcce354508c9fc016a4c1ea1@www.novabbs.org>
 <jwv34htql17.fsf-monnier+comp.arch@gnu.org>
 <2025Jan8.230846@mips.complang.tuwien.ac.at>
 <jwvr05cq4tx.fsf-monnier+comp.arch@gnu.org>
 <2025Jan9.082357@mips.complang.tuwien.ac.at>
 <b8744b4868c5f6b7ef6f629f0fbbf492@www.novabbs.org>
Injection-Date: Thu, 09 Jan 2025 22:23:31 +0100 (CET)
Injection-Info: dont-email.me; posting-host="a5323f250f3ccc2312f42a14769c3822";
	logging-data="3723036"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18vU3RqghTwPYl3kjnSwgsY5wsTynkJ/Bo="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:yYOKU46DLZxU8UiCuv5Hy3Ko7dg=
Bytes: 2926

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.html

and 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?