Hello Sir, My name is Wei-Fan Chiang. I am now a graduated student of U. of Utah. I have a question about call external function in JIT. Suppose I have a simple program: int main (int argc, char *argv[]) { int i = 2, j = 3, k; k = foo(2, 3); return 0; } "foo" is an external function (non-native function define in dynamic library) made by us. In JIT, we just need to natively execute foo and pass the result back. That means, we want to treat "foo(2, 3)" as a constant while doing JIT. Is it possible? Thanks. Regards, Wei-Fan
Jeff Fifield
2011-Oct-06 19:45 UTC
[LLVMdev] A question about calling external function in JIT
Hi Wei-Fan, It is possible to reference an external function from JITed code. You can use the llvm::sys::DynamicLibrary routines to load your dynamic library. After loading the library, the JIT engine should be able to locate 'foo'. Jeff On Thu, Oct 6, 2011 at 1:28 PM, Wei-Fan <wfchiang at cs.utah.edu> wrote:> Hello Sir, > > My name is Wei-Fan Chiang. > I am now a graduated student of U. of Utah. > I have a question about call external function in JIT. > > Suppose I have a simple program: > > int main (int argc, char *argv[]) { > int i = 2, j = 3, k; > k = foo(2, 3); > return 0; > } > > "foo" is an external function (non-native function define in dynamic > library) made by us. > In JIT, we just need to natively execute foo and pass the result back. > That means, we want to treat "foo(2, 3)" as a constant while doing JIT. > > Is it possible? > > Thanks. > > Regards, > Wei-Fan > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Jeff Fifield
2011-Oct-10 16:13 UTC
[LLVMdev] A question about calling external function in JIT
On Sun, Oct 9, 2011 at 6:51 PM, Wei-Fan <wfchiang at cs.utah.edu> wrote:> Hello Jeff, > > Many thanks for your help!! > I successfully load a function in a dynamic library by using > sys::DynamicLibrary routines.great.> But I still have another question: > How if 'foo' is defined in a static library ?? > Is it possible not compiling the static libraries by llvm and natively call > functions in them?I'm not sure I understand the question. I understand that you want to call 'foo' from JIT, and that you have figured out how to do this if 'foo' is in a dynamic library. You now want to use a static library instead? I'm not sure if that's possible, unless by static library you mean a bitcode file. In that case, you can link the bitcode library to your code before JIT (e.g. using llvm-link or llvm-ld), or you can essentially do the same thing manually in your code. This was discussed in a previous thread (http://bit.ly/oYbbsD). -Jeff> > Thanks a lots. > > Regards, > Wei-Fan > > 於 10/6/2011 1:45 PM, Jeff Fifield 提到: >> >> Hi Wei-Fan, >> >> It is possible to reference an external function from JITed code. You >> can use the llvm::sys::DynamicLibrary routines to load your dynamic >> library. After loading the library, the JIT engine should be able to >> locate 'foo'. >> >> Jeff >> >> On Thu, Oct 6, 2011 at 1:28 PM, Wei-Fan<wfchiang at cs.utah.edu> wrote: >>> >>> Hello Sir, >>> >>> My name is Wei-Fan Chiang. >>> I am now a graduated student of U. of Utah. >>> I have a question about call external function in JIT. >>> >>> Suppose I have a simple program: >>> >>> int main (int argc, char *argv[]) { >>> int i = 2, j = 3, k; >>> k = foo(2, 3); >>> return 0; >>> } >>> >>> "foo" is an external function (non-native function define in dynamic >>> library) made by us. >>> In JIT, we just need to natively execute foo and pass the result back. >>> That means, we want to treat "foo(2, 3)" as a constant while doing JIT. >>> >>> Is it possible? >>> >>> Thanks. >>> >>> Regards, >>> Wei-Fan >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> > >
Maybe Matching Threads
- [LLVMdev] A question about calling external function in JIT
- [LLVMdev] The MBlaze backend: can we remove it?
- [Fwd: [SECURITY] ftpwatch package has major security problems]
- [LLVMdev] Problems building llvm on AIX
- [LLVMdev] Errors when compiling DynamicLibrary.cpp for Debug build