Use a different function-calling convention, in which functions that take a fixed number of arguments return with the rtd instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there.
This calling convention is incompatible with the one normally used on Unix, so you cannot use it if you need to call libraries compiled with the Unix compiler.
Also, you must provide function prototypes for all functions that take variable
numbers of arguments (including printf); otherwise incorrect code is generated
for calls to those functions.
In addition, seriously incorrect code results if you call a function with too many
arguments. (Normally, extra arguments are harmlessly ignored.)
The rtd instruction is supported by the 68010, 68020, 68030, 68040, 68060 and CPU32
processors, but not by the 68000 or 5200.
The default is -mno-rtd.
-mrtd, -mno-rtd
Make StdCall calling convention the default
[1] https://github.com/llvm/llvm-project/issues/60554
[2] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/M68k/M68kExpandPseudo.cpp#L245
[3] https://gcc.gnu.org/onlinedocs/gcc/M680x0-Options.html
[4] https://clang.llvm.org/docs/ClangCommandLineReference.html
Now, the interesting part is the question why the compiler is even trying
to take this codepath since RTD should normally be turned off in the M68k >backend by default as it's the case for GCC.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 98:17:30 |
Calls: | 6,699 |
Calls today: | 4 |
Files: | 12,232 |
Messages: | 5,349,595 |