Jan Rehders
2007-Jun-27 20:16 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
Hi, attached is a small testcase I did. It builds two LLVM functions which both call two native functions get5 and get6. The native functions are in the exe and in the dll. On OS X it works like a charm. On Linux none of the two functions can be called. Maybe someone can try them or have a look at it to see if there is something obviously wrong greetings, Jan -------------- next part -------------- A non-text attachment was scrubbed... Name: codegen1.cpp Type: application/octet-stream Size: 4065 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070627/54390960/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: foo.c Type: application/octet-stream Size: 29 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070627/54390960/attachment-0001.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: makefile Type: application/octet-stream Size: 1923 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070627/54390960/attachment-0002.obj> -------------- next part --------------
Nicolas Geoffray
2007-Jun-29 08:45 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
Hi Jan, If I recall correctly, in Linux you get the message: PPCJITInfo.cpp:382: failed assertion `ResultPtr >= -(1 << 23) && ResultPtr < (1 << 23) && "Relocation out of range!"' Right? But on OS X you don't have this messsage? Here's a temporary fix until I find time to investigate on this: In function PPCISelLowering::LowerCALL, comment the lines: if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) Callee = DAG.getTargetGlobalAddress(G->getGlobal(), Callee.getValueType()); This will force an indirect call, and won't use the jump-size limitation of the bl instruction. Let me know if this helps. Cheers, Nicolas Jan Rehders wrote:> Hi, > > attached is a small testcase I did. It builds two LLVM functions which > both call two native functions get5 and get6. The native functions are > in the exe and in the dll. On OS X it works like a charm. On Linux > none of the two functions can be called. > > Maybe someone can try them or have a look at it to see if there is > something obviously wrong > > greetings, > Jan > > > > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Jan Rehders
2007-Jun-30 16:25 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
Hi,> If I recall correctly, in Linux you get the message: > > PPCJITInfo.cpp:382: failed assertion `ResultPtr >= -(1 << 23) && > ResultPtr < (1 << 23) && "Relocation out of range!"' > > > Right? But on OS X you don't have this messsage?Not exactly. There seem to be two problems. Your patch fixes one of them: in OS X I got the above error message when I first called a native function using EE->runFunction and the tried to call it again using a CallInst. This is fixed by your suggested patch, thank you The other problem is that LLVM does not find any native functions in Linux/x86. When I try to call them using a CallInst I simply get a message telling me I tried to call a non-existing function and the abort()s. I can only call standard C functions like printf. When the function is provided by a loaded dll or its part of the .exe it is not found. The -rdynamic did not solve this either. However, the functions in question are found using dlsym. I currently have no idea how to solve this (see my previous message for various attempts and their results) I will submit two bug reports when I receive my bugzilla password Greetings, Jan> Here's a temporary fix until I find time to investigate on this: > > In function PPCISelLowering::LowerCALL, comment the lines: > > if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) > Callee = DAG.getTargetGlobalAddress(G->getGlobal(), > Callee.getValueType()); > > This will force an indirect call, and won't use the jump-size > limitation > of the bl instruction. > > Let me know if this helps. > > Cheers, > Nicolas > > Jan Rehders wrote: >> Hi, >> >> attached is a small testcase I did. It builds two LLVM functions >> which >> both call two native functions get5 and get6. The native functions >> are >> in the exe and in the dll. On OS X it works like a charm. On Linux >> none of the two functions can be called. >> >> Maybe someone can try them or have a look at it to see if there is >> something obviously wrong >> >> greetings, >> Jan >> >> >> >> --------------------------------------------------------------------- >> --- >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reasonably Related Threads
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?