<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I can definitely see why you’d want to work around this selector matching stuff, but I can also understand why it’s difficult to get traction with the alternatives.
I’ll give it some thought to see if I can come up with something worth adding to the conversation, but in the mean time I’ll keep trying to fix what I’ve got.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">BTW, I’ve got five other modes of failure from the suite of 22 C++ EH tests I was running. Do you want me to file Bugzilla reports or just keep them on my
own plate for now?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The quick summary is as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assert in CloneAndPruneIntoFromInst because of an unrecognized PHINode (almost certainly a different manifestation of the problem I’m currently working on)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assert in WinEHPrepare::addStubInvokeToHandlerIfNeed because no return instruction was found.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assert in Win64Exception::emitCXXFrameHandler3Table because CatchHigh > TBME.TryHigh<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assert in MCWinCOFFStreamer::EmitLabel because the symbol being emitted was previously defined.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assert in X86DAGToDAGISel::</span>
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">getAddressOperands because non-zero placement is ignored with ES.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Reid Kleckner [mailto:rnk@google.com]
<br>
<b>Sent:</b> Friday, April 10, 2015 4:06 PM<br>
<b>To:</b> Kaylor, Andrew<br>
<b>Cc:</b> David Majnemer <david.majnemer@gmail.com> (david.majnemer@gmail.com); LLVM Developers Mailing List<br>
<b>Subject:</b> Re: [WinEH] Cloning blocks that reference non-cloned PHI nodes<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Sounds reasonable. Honestly, we've been having some serious whiteboard discussions about how to get out of doing all this selector pattern matching. I think that's basically the most fragile part of winehprepare, and if we can add some
new constructs that wrap that up in something opaque to mid-level passes, that would be great.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Unfortunately, I haven't really been able to get enough consensus to write something down. If I can't convince my coworkers that we need a new construct in person, there's not much point in writing up a detailed RFC. :(<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here's the gist of the new idea:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Leave invoke alone, too many optimizations care about it<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Add a new 'landingswitch' (name under debate) instruction that fills the landingpad role and is also a terminator<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- landingswitch clauses have some fixed operands (RTTI, handler label) and some variable number of operands as required by the EH personality (catch object, adjectives)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Allow the 'resume' instruction to have 0, 1, or 2 successors, one of which can be a landingpad.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Add a 'resume' clause to landingswitches to allow them to continue the unwind process at another landingpad in the same function<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I've tried to sell this idea, but I'm getting push back suggesting that we fix it a different way. The most compelling suggestion is to have the existing landingpad instruction produce an i8* selector instead of an i32 selector, and then
we indirectbr on it. This would save the selector pattern matching that we do today, but I don't particularly like it. Optimization passes can do basic block commoning, tail merging, and hoist instructions between the landingpad and the indirectbr, and I don't
like dealing with that.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I also don't like it because we'd need to teach the inliner about indirectbr, which today it refuses to inline.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Fri, Apr 10, 2015 at 3:45 PM, Kaylor, Andrew <<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Reid and David,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I just wanted to give you a heads up that I’m currently working on a problem where the WinEHPrepare outlining code stumbles and asserts while cloning code that references extracted
landing pad values via PHI nodes that are in intermediate blocks that aren’t being cloned. The test I’m looking at fails with an assertion claiming that llvm.eh.begincatch was called twice inside a handler.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have an idea for how to address this (giving the cloning director a chance to replace operands before an instruction is remapped). I’ll put something up for review as soon as
I have it working. In the mean time I wanted to make sure you weren’t working on the same problem.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I’m seeing it with some C++ EH tests I’m working on, but I think it may be possible for it to happen with SEH cleanup.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If you’re curious, here’s a reproducer.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> main(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">void</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">)
{</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">try</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">try</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">throw</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">'a'</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">char</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
c) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"%c\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
c);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">throw</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> 1;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
x) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"%d\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
x);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">(...) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"...\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">try</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">try</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">throw</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">'b'</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">char</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
c) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"%c\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
c);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">throw</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> 2;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
x) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"%d\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
x);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">char</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
c) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"%c\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
c);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">catch</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">(...) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> printf(</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white">"...\n"</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> 0;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">}</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">-Andy<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>