Closed jzimmerman135 closed 1 year ago
I figured out the issue. Please correct me if I am wrong, but just for the sake of others. If you use a Jit engine you cannot add to the module after you run a function, you need to create an interpreter engine to do that.
The problem I seem to get the same value returned when executing different anonymous functions.
I am looping through top level expressions and generating small functions to run them. Each time a top level expression is parsed, I append a new basic block to the module and get its
FunctionValue
. I then call it using the execution engine, viaexecution_engine.run_function(myFunctionValue, false)
, directly using theFunctionValue
generated earlier. But this always produces the same numberTo Reproduce
This produces the output:
Expected Behavior I would expect that it calls the correct function each time. So f2 res: 63, instead of 20. Since it seems to be calling the right function address.
LLVM Version:
arm64-apple-darwin22.1.0
Desktop:
Additional Context I'm new to LLVM and Inkwell so very likely just a user error, but I would appreciate any help! Thanks.