<div dir="ltr">Hi,<div><br></div><div>I think this is probably easiest to explain with code (I only provided the essentials for clarity):</div><div><br></div><div>// begin file jit.cpp</div><div><br></div><div><div>int myglobal;</div><div><br></div><div>void printMyGlobal() {</div><div>  printf("myglobal: %d\n", myglobal);</div><div>}</div><div><br></div><div>int main(int argc, char *argv[]) {</div><div><br></div><div>  // This file, jit.cpp has been compiled to bitcode (clang -S -emit-llvm jit.cpp)</div><div>  // and is read into Module M here</div><div>  Module *M = ... <br></div><div>  ExecutionEngine *ee = ...</div><div><br></div><div>  myglobal = 42;</div><div><br></div><div>  ee->addGlobalMapping(M->getGlobalVariable("myglobal"), (void*)&myglobal);<br></div><div>  ee->finalizeObject();</div><div><br></div><div>  void(*fptr)() = (void(*)())ee->getFunctionAddress("printMyGlobal");<br></div><div>  fptr();</div><div>  printMyGlobal();<br></div></div><div>}</div><div><br></div><div>// end file jit.cpp</div><div><br></div><div>I compile this file (jit.cpp) into bitcode which I then load int M. M  also contains a global variable called myglobal. I want to "map" the myglobal variable in M to the global variable in the running program. The idea is that the value of myglobal inside the JIT'ted module will also be 42. However, as it is right now, when I run the code, I get:</div><div><br></div><div>myglobal: 0</div><div>myglobal: 42</div><div><br></div><div>The first is the JIT'ted printMyGlobal() and the second is the AOT'ed printMyGlobal(). But when I lookup the address of the global variable myglobal (ee->getGlobalValueAddress()), it is mapped to the correct address. Similarly, if I lookup ee->getGlobalValueAtAddress(), I get the expected result.</div><div><br></div><div>Am I missing an important step? Is what I am trying to do even possible? </div><div><br></div><div>Thanks for the help. </div><div><br></div><div>Tarun</div><div><br></div></div>