<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 10/31/2011 2:53 AM, zhouxu(NUDT) wrote:
    <blockquote
cite="mid:CABmQd1nHObeY=a0fnm1e0G13RT1sdsFFD5WwiXbpRY4cq07=8Q@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div class="gmail_quote">Hi,
        <div>    I am new to LLVM. I want to use LLVM to instrument
          codes, such as function calls and basic blocks. But I don't
          know where to start. I wonder if there are any example codes
          to show how to instrument codes in the IR level?</div>
      </div>
    </blockquote>
    <br>
    First, have you read the Language Reference Manual, the Programmer's
    Manual, and the How to Write an LLVM Pass manual at
    <a class="moz-txt-link-freetext" href="http://llvm.org/docs">http://llvm.org/docs</a>?  Those are pretty much required reading for
    staring to learn how to write LLVM transform passes.<br>
    <br>
    As you start coding, you'll find the doxygen docs (also on that web
    page) extremely valuable.<br>
    <br>
    As for examples, you might want to take a look at some of the passes
    in the SAFECode project (<a class="moz-txt-link-freetext" href="http://sva.cs.illinois.edu">http://sva.cs.illinois.edu</a>).  The
    load/store instrumentation pass
    (safecode/lib/InsertPoolChecks/LoadStoreChecks.cpp) is a very simple
    example of a pass that instruments every load and store.  Modifying
    that code to instrument function calls and basic blocks should be
    straightforward.<br>
    <br>
    There are, of course, numerous examples in LLVM itself (in
    lib/Transforms), too, although I'm not sure which passes are going
    to be small and trivial (maybe the profiling instrumentation
    passes).<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
cite="mid:CABmQd1nHObeY=a0fnm1e0G13RT1sdsFFD5WwiXbpRY4cq07=8Q@mail.gmail.com"
      type="cite">
      <div class="gmail_quote">
        <div> </div>
        <div>    Thanks. </div>
      </div>
      <br>
      <br clear="all">
      <div><br>
      </div>
      -- <br>
      zhouxu<br>
      <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>
  </body>
</html>