[LLVMdev] Argument's types mismatch when creating CallInst.

Eli Friedman eli.friedman at gmail.com
Fri Nov 11 11:00:45 PST 2011


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




More information about the llvm-dev mailing list