[LLVMdev] How to place call(s) to functions found in other llvm modules ???

Eli Friedman eli.friedman at gmail.com
Wed Aug 31 11:11:50 PDT 2011


On Wed, Aug 31, 2011 at 10:54 AM, Mian M. Hamayun
<mian-muhammad.hamayun at imag.fr> wrote:
> Hi,
>
> I tried this as well, using the following line to add function declaration
> to the caller module.
>
> Function::Create(FT, Function::ExternalLinkage, "gcd", mod);
>
> Where "FT" is the same as before. And the output produced by the
> PrintModulePass becomes:
>
> ; ModuleID = 'GCDMain'
>
> declare i32 @gcd(i32, i32)
>
> define i32 @main() {
> EntryBlock:
>  %tmp = call i32 @gcd(i32 30, i32 50)
>  ret i32 %tmp
> }
>
> But it still fails to WriteBitcodeToFile, and produces the same error as
> before.

If you're still getting the "Referencing function in another module"
error, the call isn't referring to a declaration in the same module.

-Eli




More information about the llvm-dev mailing list