[LLVMdev] setjmp / longjmp does not work on X86

Tim Northover t.p.northover at gmail.com
Mon Feb 9 09:27:42 PST 2015


Hi Paweł,

> On Windows 64bit and Linux 64bit this code crashes. setjmp lowering pushes
> only jump address to buffer, but longjmp expects also stack pointer (rsp)
> and bsp register values to be in the buffer.

Saving those two components is the front-end's responsibility
(http://llvm.org/docs/ExceptionHandling.html#llvm-eh-sjlj-setjmp). The
best idea is probably to copy what clang produces for:

void foo(void *buf) {
  __builtin_setjmp(buf);
}

Cheers.

Tim.




More information about the llvm-dev mailing list