arrowdodger
2011-Nov-11 08:18 UTC
[LLVMdev] Argument's types mismatch when creating CallInst.
Hello. I have an .bc, which defines @foo(%type* arg1, %type* arg2, %type* arg3). Firstly, i do this: runtimeModule = getLazyIRFileModule("runtime.bc", smd, llctx); then this: fooFunction = runtimeModule->getFunction("foo"); myType = runtimeModule->getTypeByName("type"); After that, i'm creating another module: myModule = new Module("My Module", llctx); and create some AllocaInsts with type %type: AllocaInst * retZval = new AllocaInst(myType, "arg1", currentBB); Finally, i do CallInst::Create(fooFunction, args_vector, "", currentBB); Everything seems to be fine so far. Now i link two modules together and run Verifier: llvm::Linker linker("myModule", runtimeModule); linker.LinkInModule(myModule, &err); llvm::verifyModule(*linker.releaseModule()); This gives me error: Call parameter type does not match function signature! %"arg1" = alloca %type %"type 0x801e9b550"* %0 = call i32 @foo(%type* %"~3", %type* %"arg2", %type* %"arg3") What's interesting - if i dump myModule before verifying, manually put @foo and %type definitions into it, then opt -verify do not complain. Am i doing something wrong or is it a bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111111/ef8d8668/attachment.html>
Eli Friedman
2011-Nov-11 19:00 UTC
[LLVMdev] Argument's types mismatch when creating CallInst.
On Fri, Nov 11, 2011 at 12:18 AM, arrowdodger <6yearold at gmail.com> wrote:> Hello. I have an .bc, which defines @foo(%type* arg1, %type* arg2, %type* > arg3). > Firstly, i do this: > > runtimeModule = getLazyIRFileModule("runtime.bc", smd, llctx); > > then this: > > fooFunction = runtimeModule->getFunction("foo"); > myType = runtimeModule->getTypeByName("type"); > > After that, i'm creating another module: > > myModule = new Module("My Module", llctx); > > and create some AllocaInsts with type %type: > > AllocaInst * retZval = new AllocaInst(myType, > "arg1", > currentBB); > > Finally, i do > > CallInst::Create(fooFunction, args_vector, "", currentBB); > > Everything seems to be fine so far. > Now i link two modules together and run Verifier: > > llvm::Linker linker("myModule", runtimeModule); > linker.LinkInModule(myModule, &err); > llvm::verifyModule(*linker.releaseModule()); > > This gives me error: > Call parameter type does not match function signature! > %"arg1" = alloca %type > %"type 0x801e9b550"* %0 = call i32 @foo(%type* %"~3", %type* %"arg2", > %type* %"arg3") > > What's interesting - if i dump myModule before verifying, manually put @foo > and %type definitions into it, then opt -verify do not complain. > > Am i doing something wrong or is it a bug?A CallInst in one module can't reference a Function in another module. Build a declaration of foo in the module where you're building the call, and call that. -Eli
arrowdodger
2011-Nov-12 11:02 UTC
[LLVMdev] Argument's types mismatch when creating CallInst.
On Fri, Nov 11, 2011 at 11:00 PM, Eli Friedman <eli.friedman at gmail.com>wrote:> A CallInst in one module can't reference a Function in another module. > Build a declaration of foo in the module where you're building the > call, and call that. > > -Eli >Hmm, before emitting any code i've added this: Function::Create(fooFunction->getFunctionType(),fooFunction->getLinkage(),"foo",myModule); Now i see @foo declaration when dumping myModule, but the error is still same. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111112/60fb08ec/attachment.html>
Maybe Matching Threads
- [LLVMdev] Argument's types mismatch when creating CallInst.
- [LLVMdev] Argument's types mismatch when creating CallInst.
- [LLVMdev] IR blocks for calling function pointers
- [LLVMdev] MCJIT versus getLazyBitcodeModule?
- [LLVMdev] MCJIT versus getLazyBitcodeModule?