This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ping] Change static chain to r11 on aarch64
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm 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: Sun, 16 Dec 2018 00:03:36 -0500 (EST)
- Subject: Re: [ping] Change static chain to r11 on aarch64
- References: <CE69209B-F89F-4F7D-95DD-18867F153CFF@adacore.com> <54925765-e00a-e2b5-ec47-267659c8039d@arm.com> ,<B9184F5B-B6D7-4537-9695-C5191C794333@adacore.com> <DB5PR08MB103081A8877309883FE3830C83A70@DB5PR08MB1030.eurprd08.prod.outlook.com>,<1544645040.23889.4.camel@med.uni-goettingen.de> <DB5PR08MB1030F6E82F66E0292C2D630D83A70@DB5PR08MB1030.eurprd08.prod.outlook.com>
On Wed, 12 Dec 2018, Wilco Dijkstra wrote:
> I've not seen such an alternative implementation (-fno-trampolines is
> ignored on all targets I tried), but it wouldn't affect the ABI since you can
> only take the address of a nested function when you're the parent function.
Regarding the trampoline-code-on-executable-stack variant of
nested functions, don't miss one fine detail:
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.
The sublime port (to invent a soundalike term for port
maintainership alluding to unused terminology) is recommended to
pick a call-clobbered register that isn't used to carry any odd
special part of a function argument (including but not
restricted to regular function arguments and the
struct-value-regnum).
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.
Unless of course I and grep both miss something or other.
brgds, H-P