<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 4/27/15 12:45 PM, Zhoulai wrote:<br>
    </div>
    <blockquote
cite="mid:CAKV0nkeBEjfpa-GHApQrU7hgBphRSQrG=T5tnOReZFV_+OqZwg@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html;
        charset=ISO-8859-1">
      <div dir="ltr">
        <div>Hi, all<br>
          <br>
          I am wondering if it is possible to dynamically profile  LLVM
          IR? For example, if I have a </div>
        <div><br>
        </div>
        <div>void foo(){</div>
        <div><span>  A a;   </span></div>
        <div><span>  a.goo(); //invoke a virtual function of class A</span></div>
        <div><span>}</span></div>
        <div> </div>
        <div>Assume we don’t know which “goo()" of class “A” will be
          executed at run time. <br>
        </div>
      </div>
    </blockquote>
    <br>
    The DSA CallTargets pass can get you a list of possible targets for
    an indirect function call.<br>
    <br>
    <blockquote
cite="mid:CAKV0nkeBEjfpa-GHApQrU7hgBphRSQrG=T5tnOReZFV_+OqZwg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>We may want to print the  body of goo() as well as the
          bodies of the function called by goo() and etc., or do
          something along the execution trace. <br>
          <br>
          How can we do this kind of dynamic profiling? I recently
          learned some LLVM basics. It seems to me that the purpose of
          LLVM passes is static profiling, right? <br>
        </div>
      </div>
    </blockquote>
    <br>
    I don't know of a pass that does this.  However, it is trivial to
    write an LLVM pass that adds code before every indirect function
    call and prints out the address of the function that will be
    called.  Using that information, you can build a dynamic call graph.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <blockquote
cite="mid:CAKV0nkeBEjfpa-GHApQrU7hgBphRSQrG=T5tnOReZFV_+OqZwg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div> Thanks for your ideas. </div>
        <div><br>
        </div>
        <div>Zhoulai</div>
        <div><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>