Re:We found a bug in Go's ARM64 compiler
by adastra22 on Thursday October 09, 2025 @04:11AM
(#45524910)
There are some architectures that do, but they're all old RISC chips.
Re:We found a bug in Go's ARM64 compiler
by immibis on Thursday October 09, 2025 @01:08PM
(#45530382)
On some architectures there is a register reserved for assembler use, and even registers reserved for kernel use which can be changed in interrupt handlers and not changed back.
Re:We found a bug in Go's ARM64 compiler
by anyfoo on Thursday October 09, 2025 @07:44PM
(#45534171)
Yeah, I mentioned x18 on arm64 as an example for the latter one. Didn't know about the register reserved for assembly use, apparently MIPS indeed had that: $1, also known as $at, is the "assembler temporary".
Additionally, they call out interactions with the OS/execution environment. For example, x18 is the "platform register", and it's unspecified what the OS does with it. It's entirely possible that it clobbers it on context switch or during an interrupt or whatever. So don't use that one unless you have a contract with the OS itself.
But locally, i.e. "from instruction to instruction", no such convention exists to my knowledge, and you probably don't want to have registers that pseudo-instructions might trash inadvertently in general, because it means you can't optimally use these registers.
It's possible for pseudo-instructions or generally macros to be documented as, e.g., "this macro uses x3 as a temporary register and trashes it", but in my experience most macros that need additional temporary registers actually ask you to specify them as part of the macro invocation.
E.g. suppose you have a macro "weirdhash" that takes two registers and saves some kind of hash of them in a third register, but that also needs an extra register to perform its work. You would call it with:
Where x0 would be the scratch register you don't care about.