I try to add more functionality to Win64 exception handling, based on the posted patches from Charles Davis and João Matos.
But I have a question about how to map SEH handling to LLVM IR.
The basic structure of SEH in C is as follows:
// Do something.
__except (filter(GetExceptionCode(), GetExceptionInformation()))
// Handle exception
How to translate this?
- The filter expression is basically a nested function which is called with the exception code and exception information.
- The body of the __except statement is the landing pad. It is always executed if the filter expression returns 1.
- The exception machinery first asks _C_specific_handler, which calls the filter expression and possible jump to the body of the __except statement.
Everything looks fine except that I need a reference to the filter expression in order to generate the EH tables.
Is there a way to associate the filter expression with the landingpad instruction? I am qite sure that I miss here some LLVM API or idiom....