[PATCH] riscv: eliminate unreliable __builtin_frame_address(1)
Jessica Clarke
jrtc27 at jrtc27.com
Wed Jan 19 13:27:46 PST 2022
On 19 Jan 2022, at 21:07, Andreas Schwab <schwab at linux-m68k.org> wrote:
>
> On Jan 19 2022, Jessica Clarke wrote:
>
>> My point is that the only thing that can possibly read the incoming
>> frame pointer of a leaf function is the leaf function itself, and since
>> it knows where it’s putting it then there is no ABI issue, it just
>> remembers where it put it and loads it from there.
>
> llvm sidesteps that issue by always saving ra when creating a frame,
> even in a leaf function, so it can use a constant offset.
What’s your point? That’s a correct implementation, just a simple one.
If it wanted to RISCVFrameLowering::spillCalleeSavedRegisters could
easily save that information, or recompute it when trying to load s0,
it just doesn’t because there’s no need. Also saving s0 alongside ra is
deliberate, it aids debugging when calling noreturn functions (e.g.
panic in an OS kernel). So yes, we avoid complexity in LLVM by not
doing things we don’t need to; there’s nothing wrong with that and it
doesn’t mean other toolchains that do need that to be correct should
just do something wrong.
Jess
More information about the linux-riscv
mailing list