Problem with executing recompileAndRelinkFunction successively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with executing recompileAndRelinkFunction successively

Varun Agrawal-2
Hi,

I am trying to recompile a function during runtime, using JIT
compilation (not MCJIT). I choose JIT over MCJIT, because I only want
to modify a single function and not the whole module.

I am successfully able to recompile the function, but after that, the
original function definition is lost. And if I try to recompile, it
recompiles with the new function definition.

I figured out two workarounds but they don't work.
1. Clone function
   i. Before starting the program, make a clone of the function, lets
call it CloneOrigFunc.
   ii. When the function definition has to be modified, first make a
clone of CloneOrigFunc, and then replace the function call with a call
to the new clone.

2. Clone BasicBlocks
   i. Before starting the program, make a clone of the function, lets
call it CloneOrigFunc.
   ii. When the function definition has to be modified, first remove
all the basic blocks in the function definition.
   iii. Replace them with clones of basic blocks in CloneOrigFunc.
   iv. Set the successors of basic blocks, because this information is
lost, when the basic blocks are cloned. (Am I correct?)

With the second approach, if I dump the IR for the module after
changing the basic blocks, everything looks correct. But when the
recompileAndRelinkFunction(Fn) is executed, I get the error:

/home/varun/llvm-git/lib/CodeGen/MachineLICM.cpp:956: bool <anonymous
namespace>::MachineLICM::IsLoopInvariantInst(llvm::MachineInstr &):
Assertion `MRI->getVRegDef(Reg) && "Machine instr not mapped for this
vreg?!"' failed.




What am I missing?

Thanks,
Varun Agrawal
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev