[PATCH] D68542: [Mips] Always save RA when disabling frame pointer elimination

Dragan Mladjenovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 08:54:04 PDT 2019


draganm added a comment.

In D68542#1697732 <https://reviews.llvm.org/D68542#1697732>, @jrtc27 wrote:

> In D68542#1697636 <https://reviews.llvm.org/D68542#1697636>, @draganm wrote:
>
> > I don't think you can have frame-pointer based stack unwinding under current Mips ABIs, albeit this might be useful for some stack scan based unwind. Not sure tho.
>
>
> You can most of the time, you just have to scan backwards to find the function prologue. Yes, it can break, but unless you have full DWARF info you can't do much better. Both FreeBSD (sys/mips/mips/db_trace.c) and Linux (arch/mips/kernel/process.c) do instruction-based unwinding on MIPS to get a good-enough backtrace on panic, so without this they can end up terminating the backtrace early. In particular, if you want a specific instance of the issue that motivated this patch, on FreeBSD, they have a `panic` which calls `vpanic` (much like `printf` vs `vprintf`), but due to being marked `noreturn`, `$ra` is dead and thus being clobbered by the call doesn't force a save like normal, so *every* panic ends up with a useless backtrace terminating at `panic`.


I see. I haven't loked further but just removing nounwind from callee makes caller save $ra. Thanks for the concrete example.  The patch makes sense to me now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68542/new/

https://reviews.llvm.org/D68542





More information about the llvm-commits mailing list