This is a preliminary implementation of a pass to outline filter functions and exception handlers to support exception handling when compiling for the MSVC environment (that is, using the MSVC runtime personality functions). Because the MS personality functions are designed to call filter functions and exception handlers outside of the frame context in which the exception handler appears, the functions are extracted from their original location and inserted into an external function with the signature dictated by the personality function.
This patch represents a work in progress. It is not yet intended as a candidate to commit for the following reasons:
- It only outlines SEH filter functions (not finally handlers and not C++ EH handlers) but the rest should be just a matter of different heuristics to find the end points of the region to be outlined.
- It doesn’t remove the code after it has been outlined. That should be fairly simple but I didn’t want to delay discussion while implementing it.
- It depends on IR semantics that are being implemented by other in-flight patches.
- I haven’t implemented tests for it yet. So far I’ve just been manually verifying functionality in the debugger.
I hope that it will be a reasonable basis for discussion and that once the necessary design decisions have been made I will be able to quickly refactor it to become product-ready.