-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
global variables declared in module A but defined in module B are not resolved by the JIT #2978
Comments
Hi Paul, can you propose a patch? This should be easy if you are interested. |
*** Bug llvm/llvm-bugzilla-archive#3143 has been marked as a duplicate of this bug. *** |
The duped bug, pr3143 has a proposed patch. |
Benjamin Scarlet reports that my patch doesn't work for him due to recursive compilation. I think that there's a second bug here; calling getPointerToFunction on F() that contains a call to F2() should be getting a stub for F2, not trying to compile the whole function. |
2.7 version of testcase |
test case which shows cross module function linkage problem To build on OS X 10.6.2 use: g++ -g twoModuleCallTest.cpp On Linux use: g++ -g -rdynamic twoModuleCallTest.cpp |
a work in progress proposed patch |
Replace use of JITResolver::forceEmitFunctionStub(...) with JITResolver::getLazyFunctionStub(...). |
Forgot to revert JITResolver::JITCompilerFn(...) in 4254 |
Now that multiple execution engine instances can exist, a usable workaround involves having one execution engine per module, with LazyFunctionCreators installed to resolve cross-module calls and JIT them. I don't know how heavy each ExecutionEngine instance is, though. Perhaps a better idea would be to add a LazyFunctionCreator variant that returns Function instances rather than native function pointers. Obviously that won't be helpful for native library lookup, but you can not only resolve IR functions cross module, but you can also emit IR functions on demand more easily. |
mentioned in issue llvm/llvm-bugzilla-archive#3143 |
Extended Description
If you declare and use a global variable in module A and define it in module B the execution engine will not resolve the symbol in module A.
The attached modified version of HowToUseJIT.cpp shows this problem. You can manually work around this limitation by explicitly calling addGlobalMapping on the declaration using the same pointer that's mapped to the definition.
The text was updated successfully, but these errors were encountered: