[llvm-commits] [patch] Fix the inlining of invokes into invokes for libUnwind-like EH implementations

John McCall rjmccall at apple.com
Fri May 20 18:57:57 PDT 2011


I couldn't take it anymore, so I wrote up a dirty little patch to fix inlining through invokes.  The patch does two things:

1) Calls (not invokes) of _Unwind_Resume in the inlined function are turned into branches to the unwind dest of the outer invoke.

This is required because we really want to be using _Unwind_Resume to resume after a cleanup, but libUnwind and the standard personality functions don't expect us to call _Unwind_Resume without handling the exception if the action table said we were going to handle it.  This is not the ideal solution to this problem — among other things, it requires every landing pad to be capable of correctly handling a cleanup action, even if only trivially — but it's an improvement over the current situation, which actually requires every landing pad to advertise itself as having a catch-all (and then actually handle that!).  The ideal solution is not really attainable while still gluing together EH CFGs.

2) If a call to llvm.eh.selector can be found for the enclosing unwind destination, calls to llvm.eh.selector in the inlined function are augmented with the actions of the outer selector.

This allows the backend to assemble the correct set of unwind actions for a landing pad without gratuitous labor.

In no way is this patch a replacement for a proper revision of LLVM's EH IR:  the current IR is still awkward, challenging to optimize and lower to reasonable code, and almost inextricably tied to libUnwind-like unwinders and GCC-style personality functions.  But it eliminates the problems with spurious catch-alls that prevent the proper processing of uncaught exceptions, and it permits frontends to go back to emitting cleanups that call themselves cleanups  and  calls to _Unwind_Resume instead of _Unwind_Resume_or_Rethrow.

John.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: inliner.patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110520/411d4295/attachment.txt>


More information about the llvm-commits mailing list