Detail question about how to implement Win64 SEH

Hi!

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:

   __try {
     // 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....

Regards

Kai

Hi Kai,

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.

are you sure you don't mean: map LLVM IR to SEH? I.e. are you talking about
how to implement LLVM's "dwarf" exception handling intrinsics and landingpad
instruction using SEH?

Ciao, Duncan.

Hi Duncan!

Hi Kai,

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.

are you sure you don't mean: map LLVM IR to SEH? I.e. are you talking
about
how to implement LLVM's "dwarf" exception handling intrinsics and
landingpad
instruction using SEH?

Maybe my sentence was not precise enough. Yes, I want to implement LLVM's "dwarf" exception handling by using SEH. And I want to do it in a way that it is possible to map the C code below to LLVM IR.

Regards
Kai