[LLVMdev] RFC: How to represent SEH (__try / __except) in LLVM IR

Reid Kleckner rnk at google.com
Tue Dec 2 17:24:26 PST 2014


On Tue, Dec 2, 2014 at 4:15 PM, Vadim Chugunov <vadimcn at gmail.com> wrote:

> Hi Reid,
> Is this design supposed to be able to cope with asynchronous exceptions?
> I am having trouble imagining how this would work without adding the
> ability to associate landing pads with scopes in LLVM IR.
>

Yes, but not from within the same function. My proposal is to simply
outline __try bodies into another function and invoke it. __try blocks are
very uncommon, but C++ destructor cleanups are. Outlining them is
prohibitively expensive, and I am not proposing to do this. In other words,
faithfully implementing MSVC's -EHa flag is a non-goal.

If you want a higher fidelity implementation, I would not propose adding
unwind edges to basic blocks. This has been suggested in the past, but a
lot of LLVM would need to be taught about this implicit control flow.

Instead, I would propose identifying all trapping instructions and adding
intrinsics for them. Intrinsics can be called with invoke, which makes all
of the implicit CFG edges explicit. Peter Collingbourne proposed adding
iload and istore instructions, and this would basically be a less invasive
version of that. Optimizations would obviously suffer on intrinsics instead
of instructions, but that's a price you have to pay for async EH anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141202/8016615b/attachment.html>


More information about the llvm-dev mailing list