<div dir="ltr">I think there is a conflation here of slightly different things causing confusion.<div><br></div><div>LCSSA is a form of IR that is useful to some passes.</div><div><br></div><div>There are several utilities that can preserve LCSSA form when called on IR such as `InsertPreheaderForLoop`. When calling these utilities, you can choose whether or not you want the utility to preserve that form. All this does is change how the utility behaves in the face of LCSSA -- typically by adding checks for those special constructs and preserving them when present.</div><div><br></div><div>Some passes need the IR to be in LCSSA form to work correctly (often because anything else would introduce unscalable algorithmic complexity). You can put it into this form with an LCSSA pass (or by directly calling utility functions to do this in your pass), and when in this form you might use the above to preserve it while your pass works on that form.</div><div><br></div><div>The old pass manager also has a concept of both requiring and preserving an LCSSA "analysis". This is a confusing concept because LCSSA is not an analysis, it is a form of IR and a *transformation* pass to put IR into that form. However, the old pass manager allows you to use its concept of "analysis preservation" and "analysis requirement" to automatically control when to run the LCSSA transformation pass in order to have the IR in LCSSA form for the passes that expect this form. In order to not constantly have a pass automatically scheduled to re-form LCSSA after every transformation, many passes *preserve* this "analysis" with the pass manager (by ensuring IR that starts off in LCSSA form remains in it after the pass) using the API you mention and the `LCSSAID` pass "ID". Most old pass manager loop passes fall into this category.</div><div><br></div><div>However, this automatic behavior is convenient at times, but has also historically been confusing and error prone. So the new pass manager takes a different approach. There, *loop* passes are automatically given IR in LCSSA form and the loop pass manager (rather than any analysis) both introduces this form and ensures that it is not removed. Every loop pass in the new PM is required to preserve LCSSA form (either directly much like the bool parameters trigger in utility code, or by recreating it after any transformations that could have broken LCSSA form). Other kinds of passes simply call a utility to put the IR into LCSSA form at the start of their pass.</div><div><br></div><div>Hope this helps some in explaining the background and the different aspects of this.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 6, 2019 at 9:43 AM Zakharin, Vyacheslav P via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></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="RU">
<div class="gmail-m_-1180142935209077545WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Philip,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">If I want to use InsertPreheaderForLoop(), I need to pass PreserveLCSSA parameter to it.  If I get it right, I should
 use mustPreserveAnalysisID(LCSSAID) with the old pass manager and pass ‘false’ explicitly with the new pass manager.  Does it sound right?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Slava<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-1180142935209077545__MailEndCompose"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><a name="m_-1180142935209077545______replyseparator"></a><b><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> Philip Pfaffe [mailto:<a href="mailto:philip.pfaffe@gmail.com" target="_blank">philip.pfaffe@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, February 6, 2019 9:31 AM<br>
<b>To:</b> Zakharin, Vyacheslav P <<a href="mailto:vyacheslav.p.zakharin@intel.com" target="_blank">vyacheslav.p.zakharin@intel.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] right way for setting PreserveLCSSA with new pass manager<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi Slava,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">we don't preserve LCSSA in the new PM. If you need it you have to rerun LCSAA  before your pass.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Philip<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Feb 6, 2019 at 2:36 AM Zakharin, Vyacheslav P 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>
<p class="MsoNormal"><span lang="EN-US">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">mustPreserveAnalysisID(LCSSAID) cannot be used with the new pass manager, so what is the right way for querying it?  FunctionAnalysisManager::getCachedResult<LCSSAPass>(F)
 will not work, since LCSSAPass does not have a result.  Moreover, it is not an analysis
</span><span lang="EN-US" style="font-family:Wingdings">J</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Slava</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>

_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>