<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body 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>
</body>
</html>