<div dir="ltr">Can you clarify what you mean by "real SEH handling"? My company has me looking at this in the hopes that I can make LLVM capable of building windows drivers. If you mean "visual c++ style SEH", I'm fairly sure that isn't necessary for my purposes, but it would be nice. If you mean "something that works at all," then your concern about generalizing LLVM exception handling probably means that I will need to do some work learning about how exception handling is currently implemented. Do you have a link to the patch your discussing, or a revision number?<div>
<br></div><div>Thanks,<br>JB</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 31, 2014 at 6:41 AM, Kai Nacke <span dir="ltr"><<a href="mailto:kai.nacke@redstar.de" target="_blank">kai.nacke@redstar.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jb, Hi Tong,<br>
<br>
with my patch LLVM emits unwind information for Windows 64bit. The Dwarf EH encoding is used language specific data. That is the same way gcc implements SEH for Windows 64bit. (As a side note, PR18546 now contains a patch for Clang to use my patch on mingw64.)<br>

<br>
The rational behind this approach is that Windows provides support for stack unwinding (RtlUnwind etc.) but LLVM is inherently based on Dwarf EH. This approach combine both worlds. If the personality function is tolerant enough then it should also be possible to mix exceptions.<br>

<br>
If you want to make exception handling MS compatible then you can take my code as base. You only need to emit the MS handler data instead of the Dwarf data.<br>
<br>
However, at least as a first approach I would recommend to implement 32bit SEH with a similar approach. It should have some similarities to SjLj exception handling - this really helps to understand what needs to be done.<br>

<br>
"real SEH handling" requires a small function which is called to decide if the exception is handled. If yes then the handler is called. If not then stack unwinding continues (after a possible call of a cleanup handler). I found it difficult (if not impossible) to create this code based on the exception design of LLVM. IMHO, some some generalizations are required.<br>

<br>
Regards,<br>
Kai<div><div class="h5"><br>
<br>
On 31.01.2014 05:29, <a href="mailto:endlessroad1991@gmail.com" target="_blank">endlessroad1991@gmail.com</a> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi Jb,<br>
<br>
It's good to see someone step up and take a shot as this again. I<br>
dropped this because it seems to me it wasn't a high priority task for<br>
LLVM/Clang.<br>
<br>
Implementing SEH is more of LLVM work than Clang work.<br>
<br>
For 32-bit SEH, there are prologue/epilogue instruction sequence to<br>
emit, setting try-level ([ebp-4]), recovering EBP ([ebp-18h]), and all<br>
these can only happen in LLVM, not Clang. In my opinion, we should<br>
implement these as LLVM intrinsics, like the gcc ones: see<br>
<a href="http://llvm.org/docs/ExceptionHandling.html#exception-handling-intrinsics" target="_blank">http://llvm.org/docs/<u></u>ExceptionHandling.html#<u></u>exception-handling-intrinsics</a>.<br>
Also, we should emit the tables for each function, which is not a simple<br>
task either.<br>
<br>
For 64-bit SEH, things are simpler. There are no more instructions to<br>
emit than no-SEH code. We have only two tasks: emit the table for each<br>
function, and place some code right. If I remember it correctly,<br>
__finally block code should be replicated at 2 places: one in the<br>
original function as part of the normal execution path, and other one<br>
separately if anything in __try block goes south.<br>
As for the table part, I've seen some commits from Kai(as CC'ed in this<br>
email) doing it, you should ask him for details.<br>
<br>
Thanks again.<br>
<br>
--<br>
Best Regards, Tong Shen (沈彤)<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
<br>
</blockquote>
<br>
<br>
</blockquote></div><br></div>