I've looked at the documentation for the LLVM EH intrinsics, and also the Itanium ABI, and I'm stumped on a few things.
What is an exception personality function? What jobs does it perform? How would I go about creating one?
I had exactly the same question. I've just found these articles which thoroughly explains how it works, the full exception handling process, including the exact purpose of the personality function and a step-by-step implementation.
For the sake of having an answer on SO, here is a brief summary of the personality behavior when an exception occurs (but you really should look at the 18 22 articles that this guy wrote about this !):
First, it will be called once for each stack frame (lookup phase), and has to return a value (from an enumeration) telling to unwind if the current stack frame is able to catch the exception. The personality is expected to use a specific set of tables located at the end of the function in order to fetch this information.
If the stack frame can catch the exception, the personality will be called a second time with a different actions
argument (cleanup phase).