<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 1/17/19 11:19 AM, Dmitriev, Serguei N wrote:<br>
</div>
<blockquote type="cite" cite="mid:1112AE43C04F2E428633A4D42126DB32ACBCE7E8@ORSMSX111.amr.corp.intel.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 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:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;
        mso-fareast-language:EN-US;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Hi Hal,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US">On 1/16/19 6:59 PM, Dmitriev, Serguei N via llvm-dev wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">Hi all,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">We have recently encountered a problem with AssumptionCache that it does not get updated when a block with llvm.assume calls gets outlined by the CodeExtractor. As a result we end up with stale
 references to the llvm.assume calls that were moved to the outlined function in the parent function’s cache.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">The problem can be reproduced on the attached file as follows (many thanks to Andy Kaylor for creating this reproducer)</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">$ opt -slp-vectorizer -hotcoldsplit -slp-vectorizer -S -o - extract.ll</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">opt: .../llvm/lib/Analysis/CodeMetrics.cpp:107: static void llvm::CodeMetrics::collectEphemeralValues(const llvm::Function*, llvm::AssumptionCache*, llvm::SmallPtrSetImpl<const llvm::Value*>&):
 Assertion `I->getParent()->getParent() == F && "Found assumption for the wrong function!"' failed.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">...</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">The comments in the AssumptionCache seem to indicate that we should never get into this situation because AssumptionCache is supposed to be self-updating, but the case when a block with llvm.assume
 call is moved from one function to another is not correctly handled now. I wonder what the right way to fix this problem is.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">I guess a straightforward solution would be just changing CodeExtractor to clear function’s assumption cache right after extracting blocks from it, but that would require adding assumption analysis
 as a dependency to every pass that uses CodeExtractor.</span><o:p></o:p></p>
</blockquote>
<p style="margin-left:34.8pt"><o:p> </o:p></p>
<p style="margin-left:34.8pt">I don't, on first impression, have a better idea.<o:p></o:p></p>
<p style="margin-left:34.8pt"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Ok, I will probably implement this solution so far.</span><span style="color:windowtext" lang="EN-US"><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">Or maybe there could be other solutions like for example somehow extending callback mechanism to handle updates of the basic block parent. Can you please suggest any ideas?</span><o:p></o:p></p>
</blockquote>
<p style="margin-left:34.8pt"><o:p> </o:p></p>
<p style="margin-left:34.8pt">I don't think that our current ValueHandle callbacks will give us this functionality. We'd need a new callback?<o:p></o:p></p>
<p style="margin-left:34.8pt"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">I also think that existing callbacks cannot handle the case when block’s parent is changed, so something new will be needed. AssumptionCache as I understand was designed to be self-updating, so maybe
 it would be nice to maintain this property.</span></p>
</div>
</blockquote>
<p><br>
</p>
<p>I agree. Unfortunately, when writing the code I didn't think about this use case. Also, we need to weigh the cost of adding the callback vs. updating the more-rare transformation code. If the callback would appear on an otherwise hot path, it might not be
 the right trade off.</p>
<p> -Hal<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:1112AE43C04F2E428633A4D42126DB32ACBCE7E8@ORSMSX111.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D;mso-fareast-language:RU" lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D;mso-fareast-language:RU" lang="EN-US">Sergey<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p style="margin-left:34.8pt">Thanks again,<o:p></o:p></p>
<p style="margin-left:34.8pt">Hal<o:p></o:p></p>
<p style="margin-left:34.8pt"><o:p> </o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:34.8pt"><span lang="EN-US">Sergey</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New
              Roman",serif;mso-fareast-language:RU"><br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>LLVM Developers mailing list<o:p></o:p></pre>
<pre><a href="mailto:llvm-dev@lists.llvm.org" moz-do-not-send="true">llvm-dev@lists.llvm.org</a><o:p></o:p></pre>
<pre><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre>Hal Finkel<o:p></o:p></pre>
<pre>Lead, Compiler Technology and Programming Languages<o:p></o:p></pre>
<pre>Leadership Computing Facility<o:p></o:p></pre>
<pre>Argonne National Laboratory<o:p></o:p></pre>
</div>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>