Hi everybody.<br><br>I've just started learning about LLVM and didn't get too far studying the core.<br>I couldn't find the solution to my problem (if it has one) in the mailing list or the source code. The problem is: how can I redefine a function that's been called already by some other function?<br>

<br>Suppose I have 3 files, all compiled to bytecode through llvm-gcc (I think it could be clang instead).<br><br>File1.c:<br>void do_print() { print(); }<br><br>File2.c:<br>void print() { printf("File2.c\n"); }<br>

<br>File3.c:<br>void print() { printf("File3.c\n"); }<br><br>Then, I have the main file compiled to executable like this:<br>int main() {<br>  // initialize and get context (not shown)<br>  Module *file1(LoadFile("file1.bc",Context));<br>

  Module *file2(LoadFile("file2.bc",Context));<br>  Module *file3(LoadFile("file3.bc",Context));<br><br>  Linker::LinkModules(file1, file2, NULL);<br><br>  EngineBuilder builder(file1);<br>   ExecutionEngine *EE = builder.create();<br>

<br>  EE->runStaticConstructorsDestructors(false);<br>  <br>  func = EE->FindFunctionNamed("do_print");<br>  EE->runFunction(func, std::vector<GenericValue>()); <br><br>  //swap the definition of the function "print" from the one in File2.c to File3.c<br>

  swap (file1, file2, file3);<br>  <br>  EE->runFunction(func, std::vector<GenericValue>()); <br><br>  EE->runStaticConstructorsDestructors(true);<br><br>  return 0;<br>}<br><br>I can get everything before the swap working (if I comment the rest, the output is OK). I've tried to build the "swap" function many times but I can't get it to work.<br>

The expected output is:<br>File2.c<br>File3.c<br><br>If someone know how to do this or knows it's impossible, I would be very thankful. I don't even know if this is the best way to do it.<br><br>Miranda<br>