[LLVMdev] EH and call conversion integration

Chris Lattner sabre at nondot.org
Sat Nov 18 18:30:41 PST 2006


On Sat, 18 Nov 2006, [ISO-8859-2] Žiga Osolin wrote:
> I am currently trying to make EH (exception handling) possible to be
> integrated in C++. This means that C++ code can throw exceptions and
> llvm code can catch such exception and llvm can throw exceptions that
> C++ can catch (or pass through). There are quite some difficulties with
> approach:

Cool!  This is the major missing feature for full C++ support, it would be 
welcomed.

>
> * I must write ABI specific backends for EH. Since we support Visual
> Studio and GCC, two different backends should be written. I am not sure,
> however, that EH is the same on all platforms ... so drivers for EH
> should probably be platform and ABI specific ...

Right.  There are different components: the front-end and middle-end which 
lower and represent EH info, and the backend which translates it into a 
form for the specific target.  VC++ and GCC uses totally different ABIs, 
so the X86 backend will have to support both.

> * I do not know how to write code in such way, that C++ compiler nad
> llvm will be able to have the same type information for the same types
> (or to enable casts, e.g. if you throw type X extends Y and Y is known
> to C++, how will this be handled).

There is some front-end work there as well.  I don't know if GCC supports 
the VC exception handling ABI, if so, that part is done.

> I think with all these problems (and more are likely to arise), I don't
> know if it still makes sense to apply such fixes, they are too
> target/ABI specific. This leaves me with option to try the build tho
> whole engine (which is 300+k lines) with llvm-gcc. If I understand
> right, all such problems should disappear. So, if I compile, for example
> for x86 statically or with JIT, will the code be compatible (always!) at
> the end?

Yes, but we have no C++ EH implemented yet :)

If you want to start implementing C++ EH in LLVM, for either VC or GCC 
ABI's, the first step would to make it so that you can throw across an 
LLVM-compiled frame.  This requires emitting EH info for the function.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/


More information about the llvm-dev mailing list