<div dir="ltr"><div dir="ltr">On Wed, Jan 2, 2019 at 1:34 AM Markus Lavin <<a href="mailto:markus.lavin@ericsson.com">markus.lavin@ericsson.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_3850300164512298273WordSection1">
<p class="MsoNormal">To be more specific I am trying to use LVI from inside BasicAA to improve some cases that turned out to be relevant for our downstream target.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The code is in <a href="https://reviews.llvm.org/D55107" target="_blank">https://reviews.llvm.org/D55107</a> and I have problems with a failing assert in the LazyValueInfoWrapperPass destructor caused by the fact that LVI is accessed (via BasicAA) after
 it has been freed. This in turn seem to be because BasicAA is accessed after it has been freed and this brings us to the original question i.e.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Why is it that 'Basic Alias Analysis (stateless AA impl)' is freed much earlier than 'Function Alias Analysis Results' even though the latter depends on the former (at least AFAICT by looking at lib/Analysis/AliasAnalysis.cpp)?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">As far as I can tell later passes such as scheduling typically depend on AAResultsWrapperPass which in turn depend on BasicAAWrapperPass (which in my case also depend on LazyValueInfoWrapperPass). When scheduling needs to query aliasing
 it uses its AAResults handle but this may then use its BasicAA handle which may use its LVI handle and now the problem is that according to -debug-pass=Executions the latter two have been freed. For BasicAA itself this seem to be no major issue but for LVI
 it causes the failed assertion as any call into it will allocate its internal implementation but when there is no following releaseMemory called during free the assertion will fail when it is finally to be destructed.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Perhaps I have grossly misunderstood how these analysis pass dependencies are supposed to work but either way I do find it highly confusing indeed :)</p></div></div></blockquote><div><br></div><div>I don't know if the freeing of the BasicAA wrapper pass is a problem or not.</div><div><br></div><div>There is at least one bug in the patch you list: you have to specify dependencies in two different ways sadly: both with `getAnalysisUsugae` and in the `INITIALIZE_PASS_DEPENDENCY` series of macros. You've not added LVI to the latter, and that may be part of the problem.</div><div><br></div><div>But I can't say for sure. Sadly, I'm not aware of great ways to debug the legacy PM. The way I have done it at all times in the past has been to manually trace through things in the code and with a debugger. It tends to be extremely time consuming I'm afraid, and I don't really have any short cuts or tips to offer.</div><div><br></div><div>It also isn't an area I can personally invest a lot of time into... Maybe you or someone else can.</div><div><br></div><div>If you're interested in focusing on making this work in the new pass manager, I would have much more time to devote to debugging anything unexpected there. Generally, I would expect this to be much more obvious and clear (if not necessarily easier) in the new pass manager than in the old one.</div><div><br></div><div><br></div><div>To answer a somewhat separate question, for BasicAA what "stateless" means has more to do with high-level AA concepts. BasicAA doesn't precomute some special set of data-structures (or lazily compute them) that have to be updated and maintained to get accurate and precise answers. This is in contrast with most classical AA algorithms (Steensgaard, Andersens, CFL, etc., and sorry if I've misspelled any of these).</div><div><br></div><div>-Chandler <br></div><div> </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="EN-US"><div class="gmail-m_3850300164512298273WordSection1"><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks!<u></u><u></u></p>
<p class="MsoNormal">-Markus<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>> <br>
<b>Sent:</b> Tuesday, January 1, 2019 12:06 AM<br>
<b>To:</b> Markus Lavin <<a href="mailto:markus.lavin@ericsson.com" target="_blank">markus.lavin@ericsson.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] AA pass dependencies<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">The management of passes in the legacy PM is ... highly confusing.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Do you have a specific problem you're trying to solve or a specific question?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Dec 27, 2018 at 6:47 AM Markus Lavin via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div id="gmail-m_3850300164512298273gmail-m_-8236726568432716641divtagdefaultwrapper">
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">Hi,<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">Looking at the output of e.g.<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">llc -mtriple=x86_64-unknown-linux-gnu test/CodeGen/X86/pre-coalesce.ll -debug-pass=Executions<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">Why is it that 'Basic Alias Analysis (stateless AA impl)' is freed much earlier than 'Function Alias Analysis Results' even though the latter depends on the former (at least AFAICT
 by looking at lib/Analysis/AliasAnalysis.cpp)?<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black"><u></u> <u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">Thanks!<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:12pt;color:black">-Markus<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>

</blockquote></div></div>