Hi everybody, I'm currently working with LLVM (v 2.6) and I try to interpret LLVM bitcode using the c API. Here is my problem : I have two LLVMModuleRef, M1 and M2, M1 contains the function "funct()" and M2 contains a main function which call "funct()" (M2 declares "funct()" too but it doesn't define it). If I try to run the main function, I got the error "LLVM ERROR: Tried to execute unknown external function: ...". I build the interpreter giving it M1 and then I add M2. I can use the LLVMFindFunction(...) to get the functions "funct()" and "main()" and if I apply LLVMIsDeclaration(...) to these LLVMValueRef, I got false (so the interpreter should know the two functions are defined and it should be able to find their code). Is there something to do to enable the interpreter to find a function in another module ? I saw there is something like LLVMLinker::LinkModules(...) in c++ but I didn't find the c version of this function. Thanks in advance for your help, Thomas. -- View this message in context: http://old.nabble.com/Interpreter-with-multiple-modules.-tp27433312p27433312.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
I have not used the C api or the interpreter, but via JIT one can use ExecutionEngine::addGlobalMapping(...) after the function decl in the foreign module. See if there is an equivalent in the C API, which will probably work for the interpreter given that this method is declared in ExecutionEngine. Also search for a previous email thread in this list. This discussion was fairly recent, and I believe I responded to it. Hope this helps Garrison On Feb 3, 2010, at 8:53, Thomas W. wrote:> > Hi everybody, > > I'm currently working with LLVM (v 2.6) and I try to interpret LLVM bitcode > using the c API. Here is my problem : I have two LLVMModuleRef, M1 and M2, > M1 contains the function "funct()" and M2 contains a main function which > call "funct()" (M2 declares "funct()" too but it doesn't define it). If I > try to run the main function, I got the error "LLVM ERROR: Tried to execute > unknown external function: ...". > > I build the interpreter giving it M1 and then I add M2. I can use the > LLVMFindFunction(...) to get the functions "funct()" and "main()" and if I > apply LLVMIsDeclaration(...) to these LLVMValueRef, I got false (so the > interpreter should know the two functions are defined and it should be able > to find their code). > > Is there something to do to enable the interpreter to find a function in > another module ? I saw there is something like LLVMLinker::LinkModules(...) > in c++ but I didn't find the c version of this function. > > Thanks in advance for your help, > > Thomas. > -- > View this message in context: http://old.nabble.com/Interpreter-with-multiple-modules.-tp27433312p27433312.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Garrison Venn wrote:> > I have not used the C api or the interpreter, but via JIT one can use > ExecutionEngine::addGlobalMapping(...) after the function decl in the > foreign module. See if there is an equivalent in the C API, which will > probably work for the interpreter given that this method is declared in > ExecutionEngine. Also search for a previous email thread in this list. > This discussion was fairly recent, and I believe I responded to it. > > Hope this helps > > Garrison >Thanks. There is a addGlobalMapping(...) function in the C api, but it's not what I'm looking for. I want the interpreter to automatically link the two modules. What I want is the following : if the interpreter don't see the function definition in a module, then it looks at each modules I have previously added and if it find the function, then it run it just as if it was in the module. I will take a look at the previous thread as you suggest me. Thomas. -- View this message in context: http://old.nabble.com/Interpreter-with-multiple-modules.-tp27433312p27437331.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On 3 February 2010 14:13, Garrison Venn <gvenn.cfe.dev at gmail.com> wrote:> I have not used the C api or the interpreter, but via JIT one can use > ExecutionEngine::addGlobalMapping(...) after the function decl in the > foreign module. See if there is an equivalent in the C API, which will > probably work for the interpreter given that this method is declared in > ExecutionEngine. Also search for a previous email thread in this list. > This discussion was fairly recent, and I believe I responded to it. >This is interesting. I've just implemented dynamic loading of bitcode modules into lli for my project. I did this by hacking lli using the Linker class. Is ExecutionEngine::addGlobalMapping() preferred for this purpose? -- James> > Hope this helps > > Garrison > > On Feb 3, 2010, at 8:53, Thomas W. wrote: > > > > > Hi everybody, > > > > I'm currently working with LLVM (v 2.6) and I try to interpret LLVM > bitcode > > using the c API. Here is my problem : I have two LLVMModuleRef, M1 and > M2, > > M1 contains the function "funct()" and M2 contains a main function which > > call "funct()" (M2 declares "funct()" too but it doesn't define it). If I > > try to run the main function, I got the error "LLVM ERROR: Tried to > execute > > unknown external function: ...". > > > > I build the interpreter giving it M1 and then I add M2. I can use the > > LLVMFindFunction(...) to get the functions "funct()" and "main()" and if > I > > apply LLVMIsDeclaration(...) to these LLVMValueRef, I got false (so the > > interpreter should know the two functions are defined and it should be > able > > to find their code). > > > > Is there something to do to enable the interpreter to find a function in > > another module ? I saw there is something like > LLVMLinker::LinkModules(...) > > in c++ but I didn't find the c version of this function. > > > > Thanks in advance for your help, > > > > Thomas. > > -- > > View this message in context: > http://old.nabble.com/Interpreter-with-multiple-modules.-tp27433312p27433312.html > > Sent from the LLVM - Dev mailing list archive at Nabble.com. > > > > _______________________________________________ > > 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 > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100203/302f0d85/attachment.html>