<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 5/18/15 2:58 PM, Stephen Thomas
      wrote:<br>
    </div>
    <blockquote
cite="mid:CA+U9gD0m5705aCOTB_N5cHs-sRsjs2=o1KiZaMbhmb_hyoDyqw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Mon, May 18, 2015 at 3:34 PM, John
            Criswell <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote">
              <div><span>
                  <div>On 5/18/15 2:16 PM, Stephen Thomas wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">I'd like to write an inter-modular
                      analysis pass. My understanding is that this
                      should take the form of an LTO pass. However, I
                      have been unable to find any resources on the
                      mechanics of writing and running a custom LTO
                      pass. Does anyone have any pointers?</div>
                  </blockquote>
                  <br>
                </span> All you need to do is to write a ModulePass and
                modify the libLTO plugin to run it.  Writing a
                ModulePass is described in the "How to Write an LLVM
                Pass" document in the LLVM documentation. </div>
            </blockquote>
            <div><br>
            </div>
            <div>Great, that makes sense.</div>
            <div> </div>
            <blockquote class="gmail_quote">
              <div> To modify libLTO, you'll need to read the documents
                on how to install it, and you'll need to modify the
                plugin (in llvm/tools/LTO, I think).  </div>
            </blockquote>
            <blockquote class="gmail_quote">
              <div> Alternatively, you can modify the LLVM library that
                defines which passes get run when you use -O2 and -flto
                optimization, but the result is the same: you'll need to
                install a new libLTO plugin.<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Just to check my understanding: I will have to change
              LLVM source code (probably to some .cpp file in
              llvm/tools/LTO or in llvm/lib/LTO) and recompile in order
              to run my custom LTO pass? I'm double checking because for
              custom intra-modular analysis passes, it is not a
              requirement to change LLVM source code. Instead, one just
              adds the name of the .so to the opt invocation. (<a
                moz-do-not-send="true"
href="http://llvm.org/docs/WritingAnLLVMPass.html#running-a-pass-with-opt">http://llvm.org/docs/WritingAnLLVMPass.html#running-a-pass-with-opt</a>).</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    The opt command (which is really a utility program and not part of
    the compiler toolchain proper) loads LLVM passes; I believe Clang
    (which is part of the compiler toolchain proper) can as well.<br>
    <br>
    However, to the best of my knowledge, there is no way to tell the
    gold linker to load another .so file with an LLVM pass and run it
    during link-time optimization.  If there is a way, I'd like to know
    what it is.  :)<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <blockquote
cite="mid:CA+U9gD0m5705aCOTB_N5cHs-sRsjs2=o1KiZaMbhmb_hyoDyqw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div><br>
            </div>
            <div>Thanks,</div>
            <div>Steve</div>
            <div> </div>
            <blockquote class="gmail_quote">
              <div> <br>
                Regards,<br>
                <br>
                John Criswell<br>
                <br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div><br>
                    </div>
                    <div>Thanks,</div>
                    <div>Steve</div>
                  </div>
                  <br>
                  <fieldset></fieldset>
                  <br>
                  <pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><span>
</span></pre>
                  <span> </span></blockquote>
                <span> <br>
                  <br>
                  <pre cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a moz-do-not-send="true" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
                </span></div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </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>