<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 10, 2016 at 11:27 AM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="">Sean Silva <<a href="mailto:chisophugis@gmail.com">chisophugis@gmail.com</a>> writes:<br>
> On Tue, May 3, 2016 at 3:02 PM, Justin Bogner via llvm-commits <<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
>> Author: bogner<br>
>> Date: Tue May  3 17:02:31 2016<br>
>> New Revision: 268452<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268452&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268452&view=rev</a><br>
>> Log:<br>
>> PM: Port LoopRotation to the new loop pass manager<br>
</span> ...<br>
<span class="">>> --- llvm/trunk/test/Transforms/LoopRotate/basic.ll (original)<br>
>> +++ llvm/trunk/test/Transforms/LoopRotate/basic.ll Tue May  3 17:02:31 2016<br>
>> @@ -1,4 +1,6 @@<br>
>>  ; RUN: opt -S -loop-rotate < %s | FileCheck %s<br>
>> +; RUN: opt -S<br>
>> -passes='require<loops>,require<targetir>,require<assumptions>,loop(rotate)'<br>
>> < %s | FileCheck %s<br>
>><br>
><br>
> Sorry if this is a stupid question, but why do we need to explicitly<br>
> "require" the passes when the loop-rotate already declares the dependency?<br>
> (I feel like there's some part of the bigger picture that I'm missing here)<br>
<br>
</span>To be clear, there are no dependencies in the new pass manager - passes<br>
request analysis results from an analysis manager and they're calculated<br>
or returned from the cache as appropriate. Naturally, the next question<br>
one would ask is "okay then, why aren't these calculated on demand when<br>
loop-rotate asks for them?".<br></blockquote><div><br></div><div>Ah, yeah. The whole "schedule vs. cache" is one of the main differences of the new PM.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
The mechanical answer is that loop-rotate uses the `getCachedResult`<br>
API, not the `getResult` one - the difference being that<br>
`getCachedResult` only returns results if they're already calculated,<br>
and null otherwise. Hence, without the require<> in the test, there are<br>
no results.</blockquote><div><br></div><div>Ah, makes perfect sense!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> This of course leads to "why does loop-rotate use<br>
getCachedResult?"<br>
<br>
It has to. These analyses are function analyses, and a loop pass isn't<br>
allowed to cause a function analysis to run, much like a function pass<br>
isn't allowed to cause a module analysis to be run. They have to stick<br>
to their own level. This enforces correct layering and acts as a<br>
safeguard against accidentally doing extra work.<br>
<br>
That said, the "require<loops>" is redundant, since a LoopPassManager<br>
can't operate without having calculated that. There may also be an<br>
argument to be made that the LPM should implicitly calculate some other<br>
analyses, but we'd have to be careful not to do too much.<br>
</blockquote></div><br></div><div class="gmail_extra">Makes sense. But then `<span style="font-size:12.8px">+  assert((LI && TTI && AC) && "Analyses for loop rotation not available");` is not really appropriate, right? Can't we hit that assert just by passing the right arguments to opt? (by dropping the `require<*>` analyses from the passes= specification?)</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">(sorry, I'm away from the office and don't have an easy way to test locally)</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">-- Sean Silva</span></div><div class="gmail_extra"><br></div></div>