[LLVMdev] x86 unwind support

Kenneth Uildriks
Thu, 16 Jul 2009 15:34:59 -0000

1. Is there already a push underway to get it in?

2. If not, how's this change sound:

ECX is not a callee-saved register, so callers assume it gets nuked
anyway.  So for LLVM functions, ECX gets a flag indicating whether
unwinding is taking place.  At each callsite for "call", check ECX and
bail out if the unwind flag is set.  At the callsite for "invoke",
check ECX and jump to the unwind label if ECX is set; otherwise, jump
to the regular return label.

It doesn't add to register pressure since ECX gets clobbered by
function calls anyway.  It doesn't access memory for LLVM-to-LLVM
calls.  The only overhead to callsites is a conditional branch on a
register value.

Now when calling external functions, this obviously won't work.
Perhaps a thread-local global that gets checked only on returns from
external functions.  Or perhaps unwinds coming from external functions
just doesn't get supported for now.

3. Perhaps a pass that lowers unwinds to an EH intrinsic?  Would that
map well without adding more overhead than the current setjmp/longjmp
lowering pass?