<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 2/3/15 2:03 PM, Hui Zhang wrote:<br>
    </div>
    <blockquote
cite="mid:CAHUsaRF6ri=s99g6ySS63KA1n_hg6+qoYE2-uh0XXV4NzxmjGA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:georgia,serif;font-size:large">Is there
          anyone who can clear my confusion ?<br>
        </div>
      </div>
    </blockquote>
    <br>
    First, the Hello pass may not be setting the third and fourth
    arguments as it could be.<br>
    <br>
    Second, regarding their use, the third argument tells the LLVM
    PassManager that this pass never modifies a function's control-flow
    graph while the fourth argument indicates that the pass never
    modifies the LLVM IR at all.<br>
    <br>
    An analysis pass can (and probably should) set the third and fourth
    arguments to true.<br>
    <br>
    A transform (i.e., optimization) pass that never modifies the CFG,
    even though it may modify other parts of a function, can safely set
    the third argument to true and the fourth argument to false.<br>
    <br>
    The third and fourth arguments help the PassManager optimize pass
    scheduling.  Many analysis passes rely on the CFG and must be rerun
    if it is altered.  This is why the third argument exists; it tells
    the PassManager that the CFG is unmodified and that analysis passes
    using the CFG do not need to be invalidated.<br>
    <br>
    The fourth argument tells the PassManager that a pass never modifies
    the program at all and can be safely run with other analysis passes.<br>
    <br>
    In short, the arguments work exactly as described; the Hello example
    pass may not be setting them optimally, though.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <blockquote
cite="mid:CAHUsaRF6ri=s99g6ySS63KA1n_hg6+qoYE2-uh0XXV4NzxmjGA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:georgia,serif;font-size:large"><br>
        </div>
        <div class="gmail_default"
          style="font-family:georgia,serif;font-size:large">thanks ! <br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Feb 2, 2015 at 11:32 AM, Hui
          Zhang <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:wayne.huizhang@gmail.com" target="_blank">wayne.huizhang@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large">Hello,
                <br>
                <br>
              </div>
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large">I'm a
                little confused about the 3th and 4th arguments in the
                registration function, explained here: <br>
                <a moz-do-not-send="true"
                  href="http://llvm.org/releases/3.3/docs/WritingAnLLVMPass.html"
                  target="_blank">http://llvm.org/releases/3.3/docs/WritingAnLLVMPass.html</a><br>
                <br>
              </div>
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large">e.g <br>
                <pre><span>static</span> <span>RegisterPass</span><span><</span><span>Hello</span><span>></span> <span>X</span><span>(</span><span>"hello"</span><span>,</span> <span>"Hello World Pass"</span><span>,</span>
                             <span>false</span> <span>/* Only looks at CFG */</span><span>,</span>
                             <span>false</span> <span>/* Analysis Pass */</span><span>);</span></pre>
              </div>
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large"><br>
                "Lastly, we <a moz-do-not-send="true"
href="http://llvm.org/releases/3.3/docs/WritingAnLLVMPass.html#writing-an-llvm-pass-registration"
                  target="_blank"><em>register our class</em></a>
                <tt><span>Hello</span></tt>, giving it a command line
                argument “<tt><span>hello</span></tt>”, and a name
                “Hello
                World Pass”. The last two arguments describe its
                behavior: if a pass walks CFG
                without modifying it then the third argument is set to <tt><span>true</span></tt>;
                if a pass is
                an analysis pass, for example dominator tree pass, then
                <tt><span>true</span></tt> is supplied as
                the fourth argument."<br>
                <br>
              </div>
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large">In
                this simple "Hello" pass, it only look at all the
                functions and print out their name. So what's the
                difference between 3th and 4th argument here ??<br>
                <br>
              </div>
              <div class="gmail_default"
                style="font-family:georgia,serif;font-size:large">And
                since Hello pass didn't modify the module but analized
                it(as I understand), shouldn't both of them be true
                instead of false in the example ??<br>
                <br>
                thanks<span class="HOEnZb"><font color="#888888"><br
                      clear="all">
                  </font></span></div>
              <span class="HOEnZb"><font color="#888888"><br>
                  -- <br>
                  <div>Best regards<br>
                    <br>
                    <br>
                    Hui Zhang<br>
                  </div>
                </font></span></div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        <div class="gmail_signature">Best regards<br>
          <br>
          <br>
          Hui Zhang<br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
    <br>
    <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>