[LLVMdev] [PATCH] Seh exceptions on Win64

Vadim Chugunov vadimcn at gmail.com
Thu Apr 17 12:40:29 PDT 2014


So I made a patch that fixes the "missing epilogue" problem by emitting a
trap instruction for IR 'unreachable'.
A secondary use for it would be for anyone wanting to make double-sure that
'noreturn' functions, indeed, do not return.

Would LLVM devs entertain the idea of committing something like this?


On Thu, Apr 17, 2014 at 10:10 AM, Kai Nacke <kai.nacke at redstar.de> wrote:

> Hi,
>
>
> On 15.04.2014 23:44, Vadim Chugunov wrote:
>
>> Hi,
>> I am curious - how does clang deal with epilogue-less functions that
>> result from _Raise_Exception being marked 'noreturn'?
>> I've also been playing with Kai's patch, and discovered that this tends
>> to greatly confuse Windows stack unwinder in cases when noreturn call is
>> at the end of a function, so execution appears to flow directly into the
>> prologue of the next function.
>>
>
> Yes, that's true. The patch has a problem if the epilogue is dead code and
> eliminated.
>
>  It looks like MSVC solves this problem by inserting 'int 3' after calls
>> to noreturns.  This is actually the prime motivation for me wanting to
>> emit code for 'unreachable'
>> <http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-April/072145.html> ...
>>
>> Vadim
>>
>
> Yaron also pointed out that
>
> int main() { throw 1; }
>
> generates two .seh_endprologue instructions. I still did not fix this bug.
>
> Regards,
> Kai
>
>
>
>>
>> On Tue, Apr 15, 2014 at 11:43 AM, Martell Malone
>> <martellmalone at gmail.com <mailto:martellmalone at gmail.com>> wrote:
>>
>>     Hi,
>>
>>     I'd like to submit a patch to match the clang patch on the front end.
>>     http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-
>> Mon-20140414/103257.html
>>
>>     The front end doesn't need this patch to work but it's still
>> important.
>>     This is mostly based on work done by kai from redstar.de
>>     <http://redstar.de>
>>
>>
>>     Could I get some feedback on this?
>>     I'm not sure if the emitting of the register names will effect msvc.
>>
>>     Many Thanks
>>
>>     Martell Malone
>>
>>     _______________________________________________
>>     LLVM Developers mailing list
>>     LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
>> http://llvm.cs.uiuc.edu
>>
>>     http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140417/386e6b78/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Emit-trap-for-unreachable-IR-instruction.patch
Type: application/octet-stream
Size: 4564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140417/386e6b78/attachment.obj>


More information about the llvm-dev mailing list