<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 6/19/16 12:36 PM, Mehdi Amini wrote:<br>
    </div>
    <blockquote
      cite="mid:845027B0-7EBE-4868-B69B-45571AD09CE7@apple.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <br class="">
      <div>
        <blockquote type="cite" class="">
          <div class="">On Jun 19, 2016, at 8:05 AM, John Criswell <<a
              moz-do-not-send="true" href="mailto:jtcriswel@gmail.com"
              class=""><a class="moz-txt-link-abbreviated" href="mailto:jtcriswel@gmail.com">jtcriswel@gmail.com</a></a>> wrote:</div>
          <br class="Apple-interchange-newline">
          <div class="">
            <meta content="text/html; charset=utf-8"
              http-equiv="Content-Type" class="">
            <div bgcolor="#FFFFFF" text="#000000" class="">
              <div class="moz-cite-prefix">On 6/19/16 4:28 AM, Mehdi
                Amini via llvm-dev wrote:<br class="">
              </div>
              <blockquote
                cite="mid:0232184D-03EA-44D4-B689-2A7FB1BFCA4E@apple.com"
                type="cite" class="">
                <meta http-equiv="Context-Type" content="text/html;
                  charset=utf-8" class="">
                <br class="">
                <div class="">
                  <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="">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 class=""><br class="">
                  </div>
                  <div class="">Depending on other transformations isn’t
                    recommended, and isn’t supported by the
                    soon-new-passmanager I believe.</div>
                  <div class="">The expectation is that the passes are
                    added in order to the pass manager by the client.</div>
                </div>
              </blockquote>
              <br class="">
              Depending on transformation passes isn't supported by the
              legacy PassManager, either.  </div>
          </div>
        </blockquote>
        <div><br class="">
        </div>
        <div>Really? What about LCSSA for example? My impression was
          that the legacy PM does not make any distinction between
          transformations and analysis.</div>
      </div>
    </blockquote>
    <br>
    The legacy PassManager doesn't make distinctions between analysis
    and transform passes per se.  A pass is a pass; analysis passes are
    just passes that never modify the IR whereas transform passes are
    passes that may modify the IR.<br>
    <br>
    Since LLVM 2.0, the PassManager did not support the feature of using
    getAnalysisUsage<>() to dictate which transform passes were
    required to be run before a given pass.  While one could write a
    pass that could act as both a transform pass and analysis pass, the
    PassManager didn't guarantee that it could schedule such passes (I
    believe primarily due to impossible-to-schedule pass schedules).  I
    was told that the PassManager was really designed so that
    getAnalysisUsage<>() would specify analysis passes; whoever
    set up the pass pipeline was responsible for ensuring that
    prerequisite transforms were run when they needed to be run.<br>
    <br>
    Now, while the "do not schedule transform passes using
    getAnalysisUsage<>()" rule has been presented on the mailing
    list multiple times over the years, there are passes in LLVM that
    break it.  I believe some passes require UnifyExitNodes.  If you say
    LCSSA does, I'd believe it.  However, in most cases, you don't need
    this feature, and breaking the rule can generate difficult-to-debug
    messages from the PassManager.  Therefore, while the rule isn't
    followed all the time, I tell people who run into the problem not to
    require transform passes.  Historically, debugging bad pass
    pipelines has been no fun, and it's terribly difficult for new LLVM
    users.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <br>
    <blockquote
      cite="mid:845027B0-7EBE-4868-B69B-45571AD09CE7@apple.com"
      type="cite">
      <div>
        <div><br class="">
        </div>
        <div>-- </div>
        <div>Mehdi</div>
        <br class="">
        <blockquote type="cite" class="">
          <div class="">
            <div bgcolor="#FFFFFF" text="#000000" class="">Occasionally
              some passes can get away with it, but it often results in
              unschedule-able pass pipelines as above.<br class="">
              <br class="">
              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 class="">
              <br class="">
              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 class="">
              <br class="">
              Regards,<br class="">
              <br class="">
              John Criswell<br class="">
              <br class="">
              <blockquote
                cite="mid:0232184D-03EA-44D4-B689-2A7FB1BFCA4E@apple.com"
                type="cite" class="">
                <div class="">
                  <div class=""><br class="">
                  </div>
                  <div class="">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 class=""><br class="">
                  </div>
                  <div class="">— </div>
                  <div class="">Mehdi</div>
                  <div class=""><br class="">
                  </div>
                  <div class=""><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="">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="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
                  </blockquote>
                </div>
                <br class="">
                <br class="">
                <fieldset class="mimeAttachmentHeader"></fieldset>
                <br class="">
                <pre class="" wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">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">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
              </blockquote>
              <br class="">
              <p class=""><br class="">
              </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">http://www.cs.rochester.edu/u/criswell</a></pre>
            </div>
          </div>
        </blockquote>
      </div>
      <br class="">
    </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>