The current version does not always generate correct code and fails the -verify-machineinstrs test.
This patch makes the following changes:
- Require base address of jmp_buf to be in a single register. This simplifies things as there is always room for the offset in the immediate field.
- Chain longjmp with a FLUSHW to get a platform independent register window flush before going up the stack.
- Use LDX/STX for 64-bit systems.
- Simplify emitEHSjLjLongJmp with a for-loop.
- Use a register mask to force reload of data into registers after a longjmp.
- Use a call instruction to get the return address. This allows the same code to be used for 64-bit systems and with position-independent code.
I have only tested it on a 32-bit system.