[LLVMdev] Darwin vs exceptions
Chris Lattner
sabre at nondot.org
Sat Dec 8 00:00:55 PST 2007
On Dec 7, 2007, at 4:40 PM, Dale Johannesen wrote:
> So I couldn't get exceptions to work on PPC darwin. After much
> digging and confusion, there seem
> to be two separate issues.
Ok.
> The gcc testsuite is running the version of the unwinding code that
> was built with the local (llvm-)gcc,
> which doesn't work because nobody has implemented
> builtin_return_address for that target.
> So that's one problem.
That's an easy problem. I just implemented __builtin_return_address
on PPC, at least builtin_return_address(0), please let me know if that
is sufficient.
> More seriously, the version of the unwinding code installed on the
> system doesn't work either, for a
> different reason (and also doesn't work on x86 Darwin). It turns
> out the installed code has the
> following patch, which is not in the llvm-gcc source (or Apple's gcc
> sources for that matter; libgcc
> lives in a separate repository these days):
Yuck :)
> Index: gcc/unwind-dw2.c
> ===================================================================
> --- gcc/unwind-dw2.c (revision 124749)
> +++ gcc/unwind-dw2.c (working copy)
> @@ -1526,7 +1526,7 @@
> static inline _Unwind_Ptr
> uw_identify_context (struct _Unwind_Context *context)
> {
> - return _Unwind_GetIP (context);
> + return _Unwind_GetCFA (context);
> }
>
> I'm uncertain of the merit of this patch, but it's in shipping
> Leopard and works with gcc, so we're
> stuck with it.
Right, this is effectively part of the darwin ABI now.
> The effect of this is that llvm's strategy of making every C++
> selector claim that it has a catch-all
> handler at the end, as described here
> http://llvm.org/docs/ExceptionHandling.html#restrictions
> does not work in this environment. Claiming that a function has a
> catch-all handler when it does
> not causes the unwinder to go into a loop.
Okay, you're beyond my knowledge here :)
> I tried simply removing the code that does this:
>
> Index: cp/except.c
> ===================================================================
> --- cp/except.c (revision 44663)
> +++ cp/except.c (working copy)
> @@ -104,7 +104,7 @@
> lang_eh_runtime_type = build_eh_type_type;
> lang_protect_cleanup_actions = &cp_protect_cleanup_actions;
> /* LLVM local */
> - lang_eh_catch_all = return_null_tree;
> +/* lang_eh_catch_all = return_null_tree;*/
> }
>
> /* Returns an expression to be executed if an unhandled exception is
>
> and that works well for me; i.e., the gcc tests that exercise
> exceptions work as well with the
> two patches above (on x86) as they did before.
Ok, cool :) Duncan, Anton, what do you guys think about this?
> Now I need some help:
> - Why was C++ claiming that every selector has a catch-all handler?
> The documentation above just says
> the C++ personality function will terminate the program if it
> detects that unwinding the exception only results in matches with
> cleanups.
> Isn't that what's supposed to happen if there's no handler anywhere?
> - What is the right thing for Linux? Is the deletion above safe
> there?
Unsure,
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071208/d8092ab0/attachment.html>
More information about the llvm-dev
mailing list