This is the mail archive of the
mailing list for the GCC project.
Re: [ping] Change static chain to r11 on aarch64
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: "Uecker, Martin" <Martin dot Uecker at med dot uni-goettingen dot de>, "hainque at adacore dot com" <hainque at adacore dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Kyrylo Tkachov <Kyrylo dot Tkachov at arm dot com>, James Greenhalgh <James dot Greenhalgh at arm dot com>, nd <nd at arm dot com>
- Date: Mon, 17 Dec 2018 13:55:44 +0000
- Subject: Re: [ping] Change static chain to r11 on aarch64
- References: <CE69209B-F89F-4F7D-95DD-18867F153CFF@adacore.com> <email@example.com> ,<B9184F5B-B6D7-4537-9695-C5191C794333@adacore.com> <DB5PR08MB103081A8877309883FE3830C83A70@DB5PR08MB1030.eurprd08.prod.outlook.com>,<firstname.lastname@example.org> <DB5PR08MB1030F6E82F66E0292C2D630D83A70@DB5PR08MB1030.eurprd08.prod.outlook.com>,<alpine.BSF.email@example.com>
> While the choice of static-chain register does not affect the
> ABI, it's the other way round: the choice of static-chain
> register matters, specifically it's call-clobberedness.
> It looks like the current aarch64 static-chain register R18 is
> call-saved but without special provisions to save and restore
> the static chain register, i.e. the port is broken wrt.
> trampolines but may appear to work (likely as-if you got the
> call-clobberedness wrong for a special case; I haven't
> investigated). I understand the i386 port gets this right.
> The CRIS port does not, but attempts and adds another bug (you
> can't use the trampoline as a register-save area on return).
> So, changing from R18 to R11 for aarch64 seems right, as the
> latter is call-clobbered and the former is call-saved IIUC.
The AArch64 ABI defines x18 as platform specific:
On Linux it is call-clobbered, but it could be a fixed register on other
platforms (eg. a thread-local pointer). I don't think it's possible to make
it a callee-save. Still it is the wrong register to use since it already has
different uses. Using x9 would make its use as an extra argument clearer.