[LLVMdev] Calling between modules

Aaron Aaron llvmification at gmail.com
Tue Jan 15 08:47:26 PST 2008


Bill,

That is great to hear.  I must be doing something wrong.  When I try
to do this, I get ERROR: Program used external function
'myLinkedFunction' which could not be resolved!

Because of its brevity, I use getOrInsertFunction when I am creating
calls to the function in module A.  I use new llvm::Function(type,
llvm::Function::ExternalLinkage, "myLinkedFunction", moduleB) when I
am defining the function with its body in module B.  I then have an
ExecutionEngine which I constructed with an empty dummy module so that
I can use addModuleProvider and removeModuleProvider to link arbitrary
modules later.  I call addModuleProvider with module A and module B
wrapped in ExistingModuleProviders, and call getPointerToFunction.

Any ideas? If there isn't anything obviously wrong here, I can boil
this down to a snippet that reproduces the problem.  Thanks,

Aaron


Bill Wendling wrote:
> Hi!
>
> > I am fairly new to LLVM development.
>
> Welcome!
>
> > Currently I am trying to treat LLVM modules almost like ".o" files
> > in a "normal" development environment, and then calling functions
> > in one module from another module. Is this possible?
> >
> Yes! In fact, that's close to what modules are in LLVM. If you want
> to call a function outside of a .o file, then you have an external
> declaration of that function in the module, and then call it like
> normal. You link the .o files like normal to create the final
> executable.
>
> > Basically, I want self contained chunks of code with dependencies
> > on functions in other self contained chunks that get resolved at
> > JIT time. I figured since the ExecutionEngine has an
> > "addModuleProvider" function, this sort of behavior is supported.
> > If not, what is addModuleProvider's intended use?
> >
> > When I can get LLVM to do what I want, it is truly incredible!
> > Thanks for a great project!
> >
> > Aaron
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list