<div dir="ltr">I wasn't able to find where we say this in the docs, but the important thing to understand is that LLVM is currently incapable of representing non-call instructions that might throw an exception. So, in your example with the destructor, LLVM thinks there are no potentially throwing operations in this function, so there is no need to emit an exceptional destructor cleanup. I didn't read through the tables to see what actually happens in practice, but it should mostly be explained by the above.<div><div><div><br></div><div>If we do anything at all with /EHa in clang-cl, we just flip the bit that says "run destructor cleanups even when a non-C++ exception occurs". I can't remember if anyone actually hooked that up, though.<div><br></div><div>Aaron expressed interest in implementing support for non-call exceptions in LLVM. I'm happy to help review the design and code, but neither I nor anyone on my team is currently planning to work on this.</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 8, 2019 at 12:55 PM Alexandre Ganea <<a href="mailto:alexandre.ganea@ubisoft.com">alexandre.ganea@ubisoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="FR-CA">
<div class="gmail-m_-6987426247052336655WordSection1">
<p class="MsoNormal">Hello everyone,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-CA">I was wondering what is the status regarding exceptions for the windows-msvc target? The corresponding part of the documentation (llvm/decs/ExceptionHandling.rst) hasn’t been updated since 2015, was there any progress
 since?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">This is most likely known, but there’s significant divergence between the behavior of MSVC cl.exe and clang-cl.exe:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">Consider:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">void</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(136,0,0)">crash</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">() {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">  struct</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">A</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">    ~</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">A</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">()
 {}<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">  } Obj;<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">  *(</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">volatile</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> *)0x11 = 0;<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">}<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">#ifdef</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">SEH</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">  #define</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">TRY</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">__try</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">  #define</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">CATCH_ALL</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">__except</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> (1)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">#else</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">  #define</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">TRY</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">try</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">  #define</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">CATCH_ALL</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">catch</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> (...)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:gray">#endif</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><i><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(136,0,0)">main</span></i><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">() {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> 
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">TRY</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> {
</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:rgb(136,0,0)">crash</span><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black">(); }<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-CA" style="font-size:9.5pt;font-family:Consolas;color:black"> 
</span><span style="font-size:9.5pt;font-family:Consolas;color:rgb(160,0,160)">CATCH_ALL</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> {}<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black"> 
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> 0;<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black">}<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">using try/catch (SEH not defined):<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">         |               (default)               |          /EHa            |          /EHs            |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">--------------------------------------------------------------------------------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">MSVC cl  | warning [1], no unwind, crash catched |    unwind, crash catched |          crash unhandled |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">clang-cl | compilation error [2]                 |          crash unhandled |          crash unhandled |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">using __try/__except (SEH defined):<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">         |               (default)               |          /EHa            |           /EHs           |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">--------------------------------------------------------------------------------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">MSVC cl  |              no unwind, crash catched |    unwind, crash catched |          crash unhandled |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">clang-cl |              no unwind, crash catched | no unwind, crash catched | no unwind, crash catched |<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">According to Microsoft’s documentation [3],<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">                (default) means:              async exceptions + C++ exceptions, but no unwinding<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">                /EHa means:                      async exceptions + C++ exceptions, with unwinding in both cases<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">                /EHs means:                      C++ exceptions only, with unwinding<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">I’m using MSVC VS2017 15.9.16 and clang-cl from github at HEAD. In both cases I’m targeting x64.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">Using _set_se_translator [4] and /EHa does not help with clang-cl.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:9pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">Are there any plans to improve  the async exceptions unwinding in the short term?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA">Alex.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:9pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:9pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">[1] warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New"">[2] error: cannot use 'try' with exceptions disabled<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:10pt;font-family:"Courier New";color:black">[3]
</span><span style="font-size:10pt;font-family:"Courier New""><a href="https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019" target="_blank"><span lang="EN-CA">https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019</span></a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">[4]
<a href="https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-se-translator?view=vs-2019" target="_blank">
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-se-translator?view=vs-2019</a><span style="color:black"><u></u><u></u></span></span></p>
</div>
</div>

</blockquote></div>