<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> <span style="font-size:12.8px">First, you can use llvm-link to link the bitcode files together.  This will require some manual changes to the Linux Makefiles.  Once you get a single bitcode file, you can run your analysis pass via opt.  This is the approach that I used for the original SVA system for Linux 2.4.22 back before we had libLTO.</span></blockquote><div><br></div><div> </div><div>When I generate bitcode files,  I pass -emit-llvm flag to compiler command line ( clang -emit-llvm "a long list of parms"  *.c ) so that it generates .bc files during compilation.  Since -emit-llvm doesn't change the name of file output, I rename *.o file to *.bc file.</div><div>Then I run compiler  again ( clang "a long list of parms" *.c ) to generate *.o file otherwise Kbuild would break. So basically I create *.bc files next to all the  *.o files (where possible)</div><div><br></div><div>How should I modify Makefiles to link all the bitcode files together? Could you share with me some experience?</div><div>My guess is to use llvm-link to link bitcode files along with every ld command line?</div><div>For example, </div><div>For " ld -r -o init/mounts.o init/do_mounts.o init/do_mounts_initrd.o init/do_mounts_md.o; "</div><div>I'll have something like " llvm-link -o init/mounts.bc init/do_mounts.bc init/do_mounts_initrd.bc init/do_mounts_md.bc; " ?</div><div><br></div><div>Thank you!</div><div><br></div><div>Kai</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 6, 2016 at 7:53 AM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@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 bgcolor="#FFFFFF" text="#000000"><span class="">
    <div>On 1/6/16 9:41 AM, Kai Wang via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr"><br>
        <div>
          <div>Hi all,</div>
          <div><br>
          </div>
          <div>I'm trying to generate whole program bitcode files for
            linux kernel and do <span>interprocedural analysis on
              kernel.</span></div>
          <div><span><br>
            </span></div>
          <div><span>I use llvmlinux to compile kernel with clang and
               generate a bunch of bitcode files successfully.</span></div>
          <div><span>I need to link all these bitcode files together
              into a single bitcode file, so that I can run whole
              program analysis. </span></div>
          <div><span><br>
            </span></div>
          <div><span>Should I use l</span><span>ibLTO</span><span> to
              link all these bitcode files together? I guess I have to
              modify the linux kernel's build scripts and Makefiles?</span></div>
          <div>I'm kind of confused. Any suggestions?</div>
        </div>
      </div>
    </blockquote>
    <br></span>
    There are two ways to do it.<br>
    <br>
    First, you can use llvm-link to link the bitcode files together. 
    This will require some manual changes to the Linux Makefiles.  Once
    you get a single bitcode file, you can run your analysis pass via
    opt.  This is the approach that I used for the original SVA system
    for Linux 2.4.22 back before we had libLTO.<br>
    <br>
    Second, you could add your pass to libLTO and change the Linux
    Makefiles to use the -flto option.  This method should require fewer
    Makefile changes but will require you to build and install your own
    libLTO library.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div><br>
          </div>
          <div>Thank you</div>
          <div>
            <div dir="ltr"><br>
            </div>
            <div dir="ltr">Regards,
              <div>Kai</div>
            </div>
          </div>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <br>
    <pre cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
  </font></span></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Regards,<div>Kai</div></div></div>
</div>