<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello Lang, David,</p>
    <p><br>
    </p>
    <p>I am just using an ObjectLinkingLayer  and an IRCompileLayer. I
      had a look at Chapter 4 of "Building A JIT" and I found exactly
      what I needed.<br>
      <br>
      I have a working implementation.<br>
    </p>
    <p>Thanks a lot for the help,</p>
    <p>Theodor</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 05/28/2016 12:15 AM, Lang Hames
      wrote:<br>
    </div>
    <blockquote
cite="mid:CALLttgrfZEj2GucESWuUzs0Q01fTP=sv8mpUdckoyCVvinhniw@mail.gmail.com"
      type="cite">
      <div dir="ltr">H Theodoros, David,
        <div><br>
        </div>
        <div>
          <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">What
            I am trying to figure out is how the function pointer can be
            updated to point to the newly compiled version.</blockquote>
        </div>
        <div><br>
        </div>
        <div>As Dave implied, it depends on how you've set up your ORC
          stack. These days, the API directly responsible for this is
          the IndirectStubsManager (see
          llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h). If
          you have access to the appropriate IndirectStubsManager you
          just need to call the updatePointer method with the name of
          the function you want to update and the new address.</div>
        <div><br>
        </div>
        <div>If you're using the CompileOnDemand layer to compile lazily
          from IR, the problem is that that layer doesn't (currently)
          expose the IndirectStubManager for each module. I think it
          would be reasonable to add support for that if you need it
          though.</div>
        <div><br>
        </div>
        <div>So - what is your current setup?</div>
        <div><br>
        </div>
        <div>You may also be interested in the latest chapter of the
          Building A JIT tutorial series that I'm working on. There's no
          chapter text yet, but the code was just committed as r271054
          and is (hopefully) fairly readable if you're already familiar
          with Orc.</div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>Lang.</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, May 27, 2016 at 10:38 AM, David
          Blaikie <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@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 dir="ltr">+Lang<br>
              <br>
              Ultravague answer: There are a few different Orc layers
              for different levels of indirection needed for different
              levels of substitutability. One way is to indirect every
              call through global function pointers - so when you want
              to replace the function you write the new function pointer
              to the global variable. I forget which layers do which
              kinds of indirection.<br>
              <br>
              - Dave</div>
            <div class="HOEnZb">
              <div class="h5">
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">On Thu, May 26, 2016 at 11:49
                    PM, Theodoros Theododiris via llvm-dev <span
                      dir="ltr"><<a moz-do-not-send="true"
                        href="mailto:llvm-dev@lists.llvm.org"
                        target="_blank">llvm-dev@lists.llvm.org</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
                      <br>
                      I am trying to figure out how to recompile
                      functions multiple times during run-time with ORC
                      JIT<br>
                      <br>
                      and I'd appreciate any help/advice.<br>
                      <br>
                      <br>
                      My use case is t he following: every time a
                      function of interest (annotated) is called,
                      profiling data<br>
                      <br>
                      are gathered. Given enough data the function is
                      recompiled using different optimizations. This
                      happens<br>
                      <br>
                      repeatedly until the "best" optimization
                      parameters are found.<br>
                      <br>
                      <br>
                      A similar question was asked before and a solution
                      was suggested:<br>
                      <br>
                      <a moz-do-not-send="true"
                        href="http://lists.llvm.org/pipermail/llvm-dev/2015-July/088665.html"
                        rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2015-July/088665.html</a><br>
                      <br>
                      <br>
                      What I am trying to figure out is how the function
                      pointer can be updated to point to the newly<br>
                      <br>
                      compiled version.<br>
                      <br>
                      <br>
                      Thanks,<br>
                      <br>
                      Theodor<br>
                      <br>
                      _______________________________________________<br>
                      LLVM Developers mailing list<br>
                      <a moz-do-not-send="true"
                        href="mailto:llvm-dev@lists.llvm.org"
                        target="_blank">llvm-dev@lists.llvm.org</a><br>
                      <a moz-do-not-send="true"
                        href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                        rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>