<div dir="ltr"><div>I'm trying to make sense in the support for setjmp/longjmp in Clang and LLVM, with only partial success. I'll try to summarize my findings in the hope that someone can shed some light on why things are the way they are and what I'm missing.<br>
</div><div><br></div><div>Clang.</div><div><br></div><div style>Clang recognizes two forms of setjmp (all I say here applies to longjmp similarly):</div><div style>* __builtin_setjmp: gets lowered to calling the llvm.sjlj.setjmp intrinsic</div>
<div style>* setjmp() library call does not appear to be handled specially, although a no-longer-comment in a test I removed in r181468 said: </div><div style><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div style><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">"__builtin_longjmp/setjmp should get transformed into llvm.setjmp/longjmp <br>
 just like explicit setjmp/longjmp calls are."</blockquote></div></blockquote><div style><div><br></div><div style>On my Ubuntu machine, the call actually gets transcibed to calling _setjmp, but that may be due to compiler settings in system library headers.</div>
<div style><br></div><div style>LLVM.</div><div style><br></div><div style>LLVM supports two flavors of setjmp/longjmp intrinsics: llvm.{set|long}jmp and llvm.eh.sjlj.{set|long}jmp</div><div style>The latter is documented in <a href="http://llvm.org/docs/ExceptionHandling.html">http://llvm.org/docs/ExceptionHandling.html</a> and has some tests for it. The former is not documented anywhere and has no tests. The former is handled by lowering the intrinsic call to calling the actual library function in SelectionDAGBuilder.cpp</div>
<div style><br></div><div style>--------------</div><div style><br></div><div style>My questions are:</div><div style>* First of all, is this a correct summary?</div><div style>* Why the (defunct) comment in a Clang test? Was clang lowering setjmp library calls to intrinsics at some point?</div>
<div style>* Are the llvm.setjmp and llvm.longjmp intrinsics still officially supported? Being absent in the language reference and especially tests can lead one to believe they are deprecated.</div><div style><br></div><div style>
Thanks in advance,</div><div style>Eli</div><div style><br></div><div style><br></div><div style><br></div></div></div>