<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Dear Stephen,<br>
      <br>
      Kevin, one of my students, wrote an LLVM pass and run-time library
      that records and reports the number of dynamic LLVM instructions
      executed by a program.  You can find the code at
      <a class="moz-txt-link-freetext" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_hxy9243_priv-5Fanalysis&d=AwMD-g&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=IZl2XfQjcrHLHpY9-MSj86XOZr7Czo8UsENrfrnbOmc&s=oB4-8_7HWQD2RvUTfsYjlgHTVAfgzCt1L-aH_xebRPM&e=">https://github.com/hxy9243/priv_analysis</a>.  The pass you want is in
      DynCount.cpp, and the code works with LLVM mainline.<br>
      <br>
      One thing that this pass does is to alter the dynamic counts
      slightly to account for additional branches that our other
      transformation adds before analysis but will remove before code
      generation, so you may need to adjust the code slightly.<br>
      <br>
      Regards,<br>
      <br>
      John Criswell<br>
      <br>
      On 5/28/15 8:08 AM, Stephen Thomas wrote:<br>
    </div>
    <blockquote
cite="mid:CA+U9gD1=0CicKKKvx53UBcYN3smR+SRj3J=wgMNB4e8E3VyGuw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I'd like a simple and fast way to collect the number of
          times each Instruction was executed in a given run of the
          application. As far as I can tell, there are a number of
          approaches I can take:</div>
        <div><br>
        </div>
        <div>- Use PIN. This would require using DWARF debug info and
          Instruction debug info to attempt to map instructions in the
          binary to instructions in the bitcode; not 100% sure how
          accurate this will be.</div>
        <div><br>
        </div>
        <div>- Use llvm-prof. Two questions here. First, I've seen on <a moz-do-not-send="true" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_14617067_collecting-2Dllvm-2Dedge-2Dprofiling-2Dwith-2Dllvm-2Dprof&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=kf8XiNx6628Vrx9TCVI4rrnisNDMVf8ZcuKA6V0udhE&e=">Stack
            Overflow</a> an option to `opt` called
          `--insert-edge-profiling`. However, that option doesn't seem
          to be available in 3.6? Second, it appears that such profiling
          only records execution counts at the Function level, not at
          the individual Instruction level. Is that correct?</div>
        <div><br>
        </div>
        <div>- Write a new tool similar to <a moz-do-not-send="true" href="https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_AddressSanitizer.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=B48ymTvL2IOafrTkfbB7YJl2y6OdfQtG7_I7dfiuNPU&e=">AddressSanitizer.</a> This
          may work, but seems like overkill.</div>
        <div><br>
        </div>
        <div>Is there an easier way to achieve my goal that I'm missing?</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Steve</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="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cs.rochester.edu_u_criswell&d=AwMD-g&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=IZl2XfQjcrHLHpY9-MSj86XOZr7Czo8UsENrfrnbOmc&s=jhBHmY_1wNojyiagnMskIUJJylsrOb7A9nqqlEfbrhc&e=">http://www.cs.rochester.edu/u/criswell</a></pre>
  </body>
</html>