<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<div class="moz-cite-prefix">On 1/16/19 6:59 PM, Dmitriev, Serguei N via llvm-dev wrote:<br>
</div>
<blockquote type="cite" cite="mid:1112AE43C04F2E428633A4D42126DB32ACBCE5A5@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@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 lang="EN-US">Hi all,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The problem can be reproduced on the attached file as follows (many thanks to Andy Kaylor for creating this reproducer)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">$ opt -slp-vectorizer -hotcoldsplit -slp-vectorizer -S -o - extract.ll<o:p></o:p></span></p>
<p class="MsoNormal"><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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">...<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><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></p>
</div>
</blockquote>
<p><br>
</p>
<p>I don't, on first impression, have a better idea.<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:1112AE43C04F2E428633A4D42126DB32ACBCE5A5@ORSMSX111.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><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></p>
</div>
</blockquote>
<p><br>
</p>
<p>I don't think that our current ValueHandle callbacks will give us this functionality. We'd need a new callback?</p>
<p><br>
</p>
<p>Thanks again,</p>
<p>Hal<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:1112AE43C04F2E428633A4D42126DB32ACBCE5A5@ORSMSX111.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Sergey<o:p></o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>