[LLVMdev] how to use external function?

Amir Mofakhar pangan at gmail.com
Sat Mar 5 12:41:28 PST 2011


Hi there,

It will be appreciated if you help me :

I need to call an external function in LLVM bitcode but don't know how :

;ModuleID = 'm1'
define i32 @main() {
entry:
%tmp0 = call i32 @MyOwnFunction()
 ret i32 0
 }
 declare i32 @MyOwnFunction()

I use below codes to run it

$ llvm-as -f m1 -o m1.bc
$ lli 1.bc

(before it I have compiled MyOwnFunction module)

when I run this program i receive this error :
LLVM ERROR: Program used external function 'MyOwnFunction' which could not
be resolved!

I know it can not find this external function but I don't know how to define
this function in another module and use it in my modules. i used below code
for the other module :

;ModuleID = 'MyOwnFunction'
define i32 @MyOwnFunction() {
entry:
 ret i32 55
 }

should i use any especial switch to compile or what should i chane in my
codes? I received error by below command also :

$ lli -load MyOwnFunction.bc m1.bc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110305/23845983/attachment.html>


More information about the llvm-dev mailing list