[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing

Jim Grosbach grosbach at apple.com
Wed Apr 11 10:20:32 PDT 2012


On Apr 11, 2012, at 8:41 AM, Paul J. Lucas <paul at lucasmail.org> wrote:

> On Apr 8, 2012, at 10:40 PM, Bill Wendling wrote:
> 
>> On Apr 8, 2012, at 8:47 AM, Paul J. Lucas wrote:
>> 
>>> But I assume [the personality function] works only for a *nix/g++ system.  My code also needs to work when compiled on Windows using Visual Studio and I'm guessing that it needs a different personality function.  Where do I get that?
>> 
>> That's not something I'm familiar with. You may be able to use the same personality function, but I know that Windows also uses SEH for its exception handling scheme. This is not supported by LLVM.
>> 
>> My suggestion is to use clang to compile a program with exceptions on your Windows box and then use the personality function that it generates.
> 
> Assuming I do that and it works, wouldn't IR code generated on Windows then be incompatible with IR-code-compiled-to-machine-code on *nix (because it would use the wrong personality function)?

IR is not portable.

> 
> Doing all the grunt work of emitting landingpads, resumes, having to get the right personality function, etc., seems a lot more work that my original proposal of catching C++ exceptions in my C thunk functions and calling a linked-list of destructors to run myself.  This also has the benefit of not having to deal with platform-specific personality functions.
> 
> I realize I'm a newb and there may be something subtle I'm not getting, but I have to ask: why is doing the work in IR "better"?
> 
> - Paul
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list