<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 6/20/16 3:46 PM, Yuxi Chen wrote:<br>
</div>
<blockquote
cite="mid:83E2887150EB424E8D7877B912AE1FF167C3E246@xm-mbx-07-prod"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=Windows-1252">
<div>Hi,
<br>
<br>
Thanks for your reply. <br>
But I still don't know how a transform pass updates a new
analysis pass after it modifies the IR. Can you explain it
clearly? I am not familiar with pass management and invocation.
<br>
</div>
</blockquote>
<br>
Passes can have methods that allow their internal state to be
updated by other passes (the same way that their state can be
queried by other passes). For example, the alias analysis passes
have methods for querying alias information as well as methods that
allow other passes to update the aliasing information when they make
changes to the IR (so that friendly optimization passes don't
invalidate alias analysis information when they make simple
changes).<br>
<br>
Right now, your transform pass has a method which your other passes
are using to query information (I am guessing that your transform
pass is recording information on what it has done). I am suggesting
that you create a new pass (call it "RK" for "Record Keeper") that
implements this method (call it getInfo()). Additionally, the RK
pass also implements a method called setInfo() which the transform
pass uses to record any information that later passes will need. In
their getAnalysisUsage<>() method, your passes preserve the
results of the RK pass.<br>
<br>
In this way, your transform pass modifies the IR and dumps any
information needed by your analysis passes into the RK pass. The RK
pass does not modify the IR, so it doesn't create an
impossible-to-schedule pass pipeline like your transform pass does.<br>
<br>
If this isn't clear, please let me know. I see that you're from
UChicago, so I'm guessing that you need this for a research project.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<br>
<blockquote
cite="mid:83E2887150EB424E8D7877B912AE1FF167C3E246@xm-mbx-07-prod"
type="cite">
<div>
<br>
Best,<br>
Yuxi<br>
<div>
<hr tabindex="-1">
<div id="divRpF16799"><b>From:</b> John Criswell
[<a class="moz-txt-link-abbreviated" href="mailto:jtcriswel@gmail.com">jtcriswel@gmail.com</a>]<br>
<b>Sent:</b> Sunday, June 19, 2016 10:05 AM<br>
<b>To:</b> Mehdi Amini; Yuxi Chen<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>;
<a class="moz-txt-link-abbreviated" href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a>; <a class="moz-txt-link-abbreviated" href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [llvm-dev] pass invalidation<br>
<br>
</div>
<div>
<div class="moz-cite-prefix">On 6/19/16 4:28 AM, Mehdi Amini
via llvm-dev wrote:<br>
</div>
<blockquote type="cite"><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Jun 18, 2016, at 10:44 PM, Yuxi Chen
via llvm-dev <<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" class=""
target="_blank">llvm-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi All,
<div class=""><br class="">
</div>
<div class="">When I use llvm, I encounter a
problem like "unable to schedule pass A required
by C"</div>
<div class="">I investigated deeper. It's like:</div>
<div class="">I have three passes, say A, B, C(all
are on function level)</div>
<div class="">A would modify IR code. (change
instruction order)</div>
<div class=""><br class="">
</div>
<div class="">For pass B, </div>
<div class="">I would use the result of pass A, I
use addRequired<B>(), and
&getAnalysis<B>(), it works. </div>
<div class=""><br class="">
</div>
<div class="">void getAnalysisUsage(AU){</div>
<div class=""><span class="Apple-tab-span"></span>AU.addRequired<A>();</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">For pass C, it will use the results
of pass A and B. </div>
<div class="">I use the way as used for pass B,
but it failed, even for LoopInfo analysis
pass(which is the built-in analysis pass).</div>
<div class="">void getAnalysisUsage(AU){</div>
<div class=""><span class=""><span
class="Apple-tab-span"></span>AU.addRequired<A>();</span></div>
<div class=""><span class=""><span
class="Apple-tab-span"></span>AU.addRequired<B>();</span></div>
<div class=""><span class="">}</span></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">It seems because A would modify IR
code, so for pass C, I need first load pass A
then pass B, otherwise it will be invalidated. </div>
<div class="">However, when I change the using
order, I still got error "unable to schedule
pass A required by C".</div>
<div class=""><br class="">
</div>
<div class="">Does anyone encounter the same
problem before and have a solution?</div>
</div>
</div>
</blockquote>
<blockquote type="cite" class="">
<div class="">
<div class="">
<div class="">Any help is appreciated. </div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Depending on other transformations isn’t
recommended, and isn’t supported by the
soon-new-passmanager I believe.</div>
<div>The expectation is that the passes are added in
order to the pass manager by the client.</div>
</div>
</blockquote>
<br>
Depending on transformation passes isn't supported by the
legacy PassManager, either. Occasionally some passes can
get away with it, but it often results in unschedule-able
pass pipelines as above.<br>
<br>
If your transform pass does something to the code, other
passes should either infer what it did by examining the IR.
the IR contains the definitive information about the program
(because it is the program).<br>
<br>
Alternatively, you could create an analysis pass upon which
both your transform and analysis passes depend. The
transform pass would update this new analysis pass with
information on what it transformed; your later analysis
passes could then query this information. This approach is
fragile, but it could work.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote type="cite">
<div>
<div><br class="">
</div>
<div>In you case, I expect that it would “work” by
removing the dependency from C to A. If C requires B
and B requires A, by scheduling C you’ll get A, B, C
in sequence.</div>
<div><br class="">
</div>
<div>— </div>
<div>Mehdi</div>
<div><br class="">
</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">Yuxi</div>
</div>
<span class="">_______________________________________________</span><br
class="">
<span class="">LLVM Developers mailing list</span><br
class="">
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" class=""
target="_blank">llvm-dev@lists.llvm.org</a><br
class="">
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
class="" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
</blockquote>
</div>
<br class="">
<br>
<fieldset class="mimeAttachmentHeader" target="_blank"></fieldset>
<br>
<pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
</div>
</div>
</div>
</blockquote>
<br>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
</body>
</html>