Messages in this thread | | | Subject | Re: [PATCH] riscv: eliminate unreliable __builtin_frame_address(1) | From | Jessica Clarke <> | Date | Wed, 19 Jan 2022 19:05:13 +0000 |
| |
On 19 Jan 2022, at 10:58, Andreas Schwab <schwab@linux-m68k.org> wrote: > > On Jan 17 2022, Jessica Clarke wrote: > >> Yes, this is a bug, that is always wrong. LLVM gets this right. > > Is that an ABI requirement? In case of a leaf function, gcc saves the > caller's frame pointer in the first slot, not the second (it doesn't > save the return address).
Leaf functions by definition don’t have callees that are trying to read their frame pointer so aren’t relevant here. The stack frame layout isn’t specified by the ABI, only that the in-memory outgoing arguments be at the bottom when calling other functions. However, GCC knows what layout it uses, so it should be consistent and follow that layout for walking back up frames. Especially for __builtin_frame_address(1), that just pertains to the current function’s frame, which it clearly knows without a doubt, so there’s no reason to get that wrong. Accessing 0(s0) is just straight up wrong, that’s accessing past the top of the stack frame, which is never going to make any sense.
Jess
| |