[lld] [lld][ELF] Add range extension thunks for x86-64 (PR #180266)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 9 03:34:51 PST 2026


https://github.com/smithp35 commented:

> * Is R11 the right choice? What about R10? R10 is used by nested functions (unsupported by Clang) as a static chain pointer, so it probably should be avoided.
> * Should this be documented in the psABI as a linker extension?

An aside on what we thought about for the Arm/AArch64 ABI. 
* Which relocations is a static linker permitted to add thunks for? Code-generators need to know this is if there are inter-procedural scratch registers that may be clobbered by the static linker.
* What the inter-procedural scratch registers are. Arm has one, and AArch64 has two.

ABI ref:
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#651use-of-ip0-and-ip1-by-the-linker

To an extent the inter-procedural scratch register is just a caller saved (volatile) register. I guess it helps reserve that in the ABI so it doesn't clash with other calling conventions that  reserve the same register for other purposes.

https://github.com/llvm/llvm-project/pull/180266


More information about the llvm-commits mailing list