[LLVMdev] Query regarding CallInst::Create

Sriseshan S srisesha at ualberta.ca
Thu Jun 20 18:15:56 PDT 2013


Hello,

I have been trying to plugin a function into a loop using a LoopPass.
However, I get the error:

> Referencing function in another module!
> %2 = call i32 @test_print()

and eventually a coredump.

Details are as follows:
There is a function called int test_print() {...}

It is being declared in the module using:

> func = mod->getOrInsertFunction("test_print", Type::getInt32Ty(ctx),
> (Type*)0);
> f = cast<Function>(func);


The call instruction is being inserted using:

> Instruction *newInst = CallInst::Create(f, "", topInst);


Any help wrt this error would be really appreciated.
Thanks.

PS: Though similar, this is different from
http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-August/042845.html as I do
not make use of builder.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130620/81878293/attachment.html>


More information about the llvm-dev mailing list