Exception handling support for a target

The high level of what happens is that __builtin_eh_return forces a spill of all the non-volatile registers. The unwinder then has a starting point for populating and adjusting those non-volatile registers.

This approach usually requires that the function calling __builtin_eh_return be built without optimizations, because the optimizer will then remove the spills.

​Ben, thanks for your input. However, I don't quite understand what you
said.

​The prototype of ​__builtin_eh_return (offset, handler) [1], I can't see
why it forces spilling all non-volatile registers (I assume non-volatile ==
callee-saved).

​Take libgcc as an example, __built_eh_return is called in
uw_install_context [1], which is called in the end of
_Unwind_RaiseException [2]. Do you mean we should compile libgcc without
optimization?

​[1] https://github.com/gcc-mirror/gcc/blob/master/libgcc/unwind-dw2.c​
[2] https://github.com/gcc-mirror/gcc/blob/master/libgcc/unwind.inc​

I apologize. I had __builtin_eh_return confused with __builtin_unwind_init. __builtin_unwind_init is the intrinsic that forces a register spill. I don’t recall the purpose of __builtin_eh_return, and I don’t have access to the source that can clear that up.