<div dir="rtl"><div dir="ltr">Hi Adrian,</div><div dir="ltr"><br></div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">freeMachineCodeForFunction is required but </span><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">recompileAndLinkFunction is not,</span></div>

<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">you can use </span>getFunction() always.<br></div><div dir="ltr"><br></div><div dir="ltr">Try to  M->dump() calling M->getFunction() where M is the Module *.</div>

<div dir="ltr">See if how the changes appear in the module dump as expected.</div><div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote"><div dir="ltr">2014-06-29 5:56 GMT+03:00 Adrian Ortega <span dir="ltr"><<a href="mailto:elfus0.1@gmail.com" target="_blank">elfus0.1@gmail.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


  

    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Hello,<br>
    <br>
    The problem I'm having is that I modify a function body by using
    'Value::replaceAllUsesWith' and then execute it with the JIT engine
    several times but I always get the output from the first iteration
    for all the iterations.<br>
    <br>
    This is what I do:<br>
    <br>
    <br>
    I generate the following 2 functions on the fly based on the
    FunctionType of the declaration below in C code.<br>
        <br>
    <blockquote><font face="Courier New, Courier, monospace">define i32
        @get_int_5(i32, i32) #1 {</font><br>
      <font face="Courier New, Courier, monospace">  ret i32 5</font><br>
      <font face="Courier New, Courier, monospace">}</font><br>
      <br>
      <font face="Courier New, Courier, monospace">define i32
        @get_int_10(i32, i32) #1 {</font><br>
      <font face="Courier New, Courier, monospace">  ret i32 10</font><br>
      <font face="Courier New, Courier, monospace">}</font></blockquote>
    I have the following C code:
    <blockquote><br>
      <font face="Courier New, Courier, monospace"><font face="Courier
          New, Courier, monospace">// This is only a declaration<br>
          // I use this FunctionType to generate the functions above<br>
        </font>int sum(int a, int b); <br>
        <br>
        int get_int()<br>
        {</font><font face="Courier New, Courier, monospace"><font face="Courier New, Courier, monospace"><br>
        </font>    return sum(a,b); <br>
        }<br>
        <br>
      </font></blockquote>
    I replace the  call to 'sum()' by calling Value::replaceAllUsesWith
    for one of the functions generated above, run with JIT. I checked
    the code generated and it actually changes the call from 'sum()' to
    'get_int_5()' and I get a 5 as return value when I call the function
    with the JIT execution engine.<br>
    <br>
    Then I repeat the previous step using 'Value::replaceAllUsesWith'
    for the next function I generated and run it with JIT. Then again
    the code generated is what I expected, this time<br>
    function call changes from 'sum()' to 'get_int_10()', however the
    problem is I get a 5 instead of a 10.<br>
    <br>
    I tried 'recompileAndLinkFunction' as well as
    'freeMachineCodeForFunction' and I always get the return value from
    the first function, and not the second as I should even though the
    generated code that I dump() says that it has the correct function
    call.<br>
    <br>
    I am using version 3.4 for both clang and llvm. And also I'm using
    the JIT Engine and not the MCJIT.<br>
    <br>
    Do you have have any idea why the references or 'uses' changes are
    not reflected in the code JIT'ed ?<br>
    <br>
    Regards.<br>
    <blockquote><br>
    </blockquote>
        <br>
    <br>
    <br>
    <br>
    <br>
  </div>

<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>