<div dir="ltr">It sounds like basicaa is not getting added somehow.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 21, 2016 at 10:49 AM, Geoff Berry <span dir="ltr"><<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi George,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">After digging a little deeper, it appears that readonly calls showing up as MemoryDefs is only happening on an EarlyCSE test that is using the new pass manager (test/Transforms/EarlyCSE/basic.ll test5 if you’re curious), so I suspect it is an issue with the new pass manager setup code for either MemorySSA, my changes to EarlyCSE, the test run command line or something else not related to the MemorySSA code proper.<u></u><u></u></span></p><span class=""><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><div style="border:dashed #2f6fab 1.0pt;padding:12.0pt 12.0pt 12.0pt 12.0pt;background:#f9f9f9"><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9;border:none;padding:0in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">--<u></u><u></u></span></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9;border:none;padding:0in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Geoff Berry<u></u><u></u></span></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9;border:none;padding:0in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Employee of Qualcomm Innovation Center, Inc.<u></u><u></u></span></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9;border:none;padding:0in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<u></u><u></u></span></p></div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p></span><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> George Burgess [mailto:<a href="mailto:gbiv@google.com" target="_blank">gbiv@google.com</a>] <br><b>Sent:</b> Wednesday, April 20, 2016 3:29 PM<br><b>To:</b> Geoff Berry <<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>><br><b>Cc:</b> Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span></p><div><div class="h5"><br><b>Subject:</b> Re: [LICM][MemorySSA] Converting LICM pass to use MemorySSA to avoid AliasSet collapse issue<u></u><u></u></div></div><p></p></div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">Hi!<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">> readonly calls are treated as clobbers by MemorySSA which leads to extra walking of MemoryDefs to not regress some EarlyCSE test cases</span><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">Can you share a testcase for this too, please? Specifically, the first test in test/Transforms/Util/MemorySSA/function-mem-attrs.ll shows that we should treat readonly calls + calls to readonly functions as MemoryUses, so if we're thinking they're clobbers somehow, that sounds like a bug...<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Thank you!<u></u><u></u></p></div><div><p class="MsoNormal">George<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Wed, Apr 20, 2016 at 12:06 PM, Geoff Berry <<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in"><div><div><p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">1)</span><span style="font-size:7.0pt;color:#1f497d">      </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Sounds good.  This isn’t holding me up so I’ll just try to keep an eye out for these changes.</span><u></u><u></u></p><p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p><p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">2)</span><span style="font-size:7.0pt;color:#1f497d">      </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I’ve attached an example IR file and debug log of where the caching is going bad.  It depends on my changes to EarlyCSE, but hopefully it is clear from the debug output what is going on.  Let me know if there is a better way to get this repro case to you.  Also, I’ll be on IRC for the next couple of hours if you would like to have a quicker discussion.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p><div style="border:dashed #2f6fab 1.0pt;padding:12.0pt 12.0pt 12.0pt 12.0pt"><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">--</span><u></u><u></u></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Geoff Berry</span><u></u><u></u></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Employee of Qualcomm Innovation Center, Inc.</span><u></u><u></u></p><p class="MsoNormal" style="line-height:15.6pt;background:#f9f9f9"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</span><u></u><u></u></p></div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Daniel Berlin [mailto:<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>] <br><b>Sent:</b> Wednesday, April 20, 2016 1:06 PM<br><b>To:</b> Geoff Berry <<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>>; George Burgess <<a href="mailto:gbiv@google.com" target="_blank">gbiv@google.com</a>><br><b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br><b>Subject:</b> Re: [LICM][MemorySSA] Converting LICM pass to use MemorySSA to avoid AliasSet collapse issue</span><u></u><u></u></p></div></div><div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Wed, Apr 20, 2016 at 9:58 AM, Geoff Berry <<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt"><div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Daniel,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks for the info.  I’ve started looking into converting EarlyCSE to use MemorySSA first since 1) I don’t think it needs any additional MemorySSA update API and 2) the particular case I’m looking at needs EarlyCSE to catch more load cases before LICM to be profitable.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I have a prototype working, but have run into two issues:</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> </span><u></u><u></u></p><p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">1)</span><span style="font-size:7.0pt;color:#1f497d">      </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">readonly calls are treated as clobbers by MemorySSA which leads to extra walking of MemoryDefs to not regress some EarlyCSE test cases.  This isn’t a huge deal, I’m just wondering if it is intentional or something that just hasn’t been gotten to yet.</span><u></u><u></u></p></div></div></blockquote><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">George is working on the optimizations, of which this is one.<u></u><u></u></p></div><div><p class="MsoNormal">I think this is one of the ones his current patch (under review) addresses.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt"><div><div><p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">2)</span><span style="font-size:7.0pt;color:#1f497d">      </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">There seems to be a bug in the CachingMemorySSAWalker invalidation causing it to return MemoryAccess nodes that have been removed.  In the case I’m seeing, a call node is removed from MemorySSA which causes CachingMemorySSAWalker::invalidateInfo() to clear the CachedUpwardsClobberingCall map.  However, this same call node is present as a value in the CachedUpwardsClobberingAccess map,</span><u></u><u></u></p></div></div></blockquote><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Unless i'm missing something, this should not have happened, and we should assert they are not being added to the cache.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">The truth is the caching parts are complicated and ugly. It was meant to be a pretty simple cache, but it's known to be inefficient (memory wise) and it's on the list of things to clean up and make sane.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal" style="margin-bottom:12.0pt">Do you have a testcase where this happens?<u></u><u></u></p></div><div><p class="MsoNormal">A quick glance says we check whether it's a call in all the right places, which means there must be a place we are not *setting* isCall properly.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div></div></div></div></div></div></div></div></div></blockquote></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div></div></div></blockquote></div><br></div>