[LLVMdev] Detail question about how to implement Win64 SEH

Kai kai at redstar.de
Mon Sep 17 21:52:26 PDT 2012


Hi Duncan!

On 17.09.2012 19:51, Duncan Sands wrote:
> 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

>
> Ciao, Duncan.
>
>>
>> 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
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list