[LLVMdev] RFC: Replace __cxa_begin_catch/__cxa_end_catch with intrinsics

John McCall
2015-02-03T03:05:32Z

> On Feb 2, 2015, at 6:04 PM, Reid Kleckner <rnk at google.com> wrote:
> I actually like the unified intrinsic approach here. The backend already
has to know things about the personality function. Until recently we would
assume that the personality function wants an Itanium LSDA, for example, and
dump that out into a target-specific section. Now on Windows we look at the
personality function and try to figure out what kind of preparation and tables
it wants.
>
> It seems reasonable then that we could continue along the lines of
classifying some personalities as "Itanium" personalities and lowering
these new intrinsics out to __cxa_begin_catch / end_catch.

You are over-estimating how similar the code-generation patterns are going to be
here.  The information flow from the unwind mechanism to the catch clause can
differ quite wildly.

Go look at what happens in the different ABIs when an exception with a
non-trivial copy constructor is caught.  There’s an entire copy-construction
that’s explicit in Itanium but which I believe is done implicitly by the
personality equivalent in MSVC (necessarily, if you understand the purpose of
__cxa_begin_catch/__cxa_end_catch).

I agree that we should be more explicit about modeling the differences in
personality-mandated code generation.  Perhaps if we did this, people would stop
talking about the “Itanium LSDA” when they mean the gcc/g++ LSDA.  I just think
there is zero benefit in pretending that we can actually model every useful
difference between personalities with the name of the personality function.

> We already do it for resume -> _Unwind_Resume.

resume was specifically designed to be unwinder-agnostic.  This is why it takes
all the data from the landingpad even though _Unwind_Resume only needs the
exception pointer.

John.